The function of the where phrase in the sql command is to specify the selection criteria and filter records; if you need to conditionally select data from the table, you can add the WHERE clause to the SELECT statement.
The WHERE clause is used to filter records. The WHERE clause is used to extract records that meet specified conditions.
To conditionally select data from a table, add a WHERE clause to the SELECT statement.
SQL WHERE syntax
SELECT column_name,column_name FROM table_name WHERE column_name operator value;
The following operators can be used in the WHERE clause:
Operator | Description |
---|---|
= | equals |
<> | is not equal to |
> | is greater than |
< | is less than |
>= | greater than or equal to |
<= | less than or equal to |
BETWEEN | Search for a certain pattern within a certain range |
LIKE |
Use WHERE clause
If you only want to select people living in the city "Beijing", we need to add a WHERE clause to the SELECT statement:
SELECT * FROM Persons WHERE City='Beijing'
Result:
For more related knowledge, please visit: PHP Chinese website
!The above is the detailed content of What is the function of where phrase in sql command?. For more information, please follow other related articles on the PHP Chinese website!