Get the App
SLTechnology News&Howtos  ›  Database  › 

Introduction to MySQL database-- where clause, combined where clause

Shulou Source: shulou.com Published: 2022-06-01 14:55:13 10月04日 Update

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

Tags: Condition operator clause data wildcard search field range order combination complex multiple character statement sort between two advantages examples text Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Redmi Microsoft Linux OPPO Reno Docker