In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Today, Xiaobian will share with you the relevant knowledge points on how to use the where query statement in mysql. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you will gain something after reading this article. Let's find out together.
In mysql, the where statement is often used in conjunction with the SELECT statement to specify the query condition, the syntax is "SELECT * FROM data table name WHERE query condition;";where statement can read the specified data according to the field value in mysql table.
Operating environment of this tutorial: Windows 10 system, mysql version 8.0.22, Dell G3 computer.
How to use the where query statement in mysql
We know that SQL SELECT statements are used to read data from MySQL tables.
To conditionally select data from a table, add a WHERE clause to a SELECT statement.
syntax
The following is the common syntax for SQL SELECT statements to read data from a data table using the WHERE clause:
SELECT field1, field2,... fieldN FROM table_name1, table_name2... [WHERE condition1 [AND [OR]] condition2.....
You can use one or more tables in a query statement, separated by commas, and WHERE statements to set the query criteria.
You can specify any condition in the WHERE clause.
You can specify one or more conditions using AND or OR.
The WHERE clause can also be applied to SQL Delete or UPDATE commands.
The WHERE clause is similar to the if condition in the programming language, reading the specified data based on the field value in the MySQL table.
Examples are as follows:
1. Filter by relational operator
equals =
greater than>
>=
<10 and name='Zhang San' ##Query data with age greater than 10 and name equal to 'Zhang San' select * from student where not name='' ##Query data whose name is not equal to "Zhang San".
3. Scope query
in
between large and small values
following are examples
select * from student where age in (10,11) ##Query for data with age equal to 10 or 11. select * from student where age=10 or age=11 ##is equivalent to the above statement. select * from student where age between 10 and 24 ##Query age between 10 and 24, including boundary values.
4. Empty judgment
select * from student where address is null Select * from student where address is not null ##Query data whose address is not null
5. Fuzzy query
like
% represents any number of characters (including 0)
_represents any character
escape: Remove wildcard properties from % or_characters
following are examples
select * from student where name like 'Wang %' ##Query the data of surname Zhang in name. select * from student where name like 'Zhang_ ##Query the data of Zhang with two characters in name. select * from student where name like '%A%%' escape 'A' ##Query name contains "%" data above is "mysql where query statement how to use" All the contents of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.