Introduction to MySQL database-- where clause, combined where clause
The where clause of the select statement specifies that the search criteria filter the data displayed.
(1) use the where clause
In the select statement, the where clause is given after the from clause and returns data that meets the specified search criteria:
Select prod_name, prod_price from Products where prod_price = 3.49
# retrieve two columns from the Products table: prod_name, and prod_price, provided that only rows with a prod_ print value of 3.49 are displayed.
In addition to the equality condition judgment in the above example, the where clause also supports the following conditional operators:
For example, use the operator (or! =) to check for mismatches:
Select vend_id, prod_name from Products where vend_id 'DLL01'
# display vend_id, and prod_name from the Products table, but only if vend_id is not DLL01.
As another example, use the between operator to match values within a range. You need to specify the end value of the range:
Select prod_name, prod_price from Products where prod_price between 5.99 and 9.49
# display prod_name, prod_price from the Products table, but only if the price is between $5.99 and $9.49 (inclusive)
(2) combine where clauses
(1) SQL also allows you to combine multiple where clauses using the and or or operators, such as the and operator:
Select prod_id, prod_price, prod_name from Products where vend_id = 'DLL01' AND prod_price