In this post, we will see the usage of the WHERE clause in MySql along with select to fetch more specific data. Where clause is used to fetch the data by providing some specific condition, if that condition is met, then we can print that data using our select statement.
For numeric type column
select * from table_name WHERE ID = 1;
For text type column
If the column contains the text values, then specify them in quotes like below. A name is a column in a table where it contains text values.
select * from table_name WHERE Name = 'John'
Operators in where clause:
|=||Equals to||Can return a specific value.|
|>||Greater than||Returns value greater than the mentioned.|
|<||Less than||Returns value less than the mentioned.|
|>=||Greater than equals to||Returns value greater than the mentioned(including mentioned).|
|<=||Less than equals to||Returns value less than the mentioned(including mentioned).|
|!=||Not equals to||Returns value excluding mentioned.|
|BETWEEN||between operator||Return the value between a certain range.|
|LIKE||like operator||Returns the value if provided pattern is matched.|
|IN||in operator||To specify multiple possible values for columns.|