WHERE clause in MySql

Where Clause Blog banner

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.

WHERE Clause

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:

OperatorNameUsage
=Equals toCan return a specific value.
>Greater thanReturns value greater than the mentioned.
<Less thanReturns value less than the mentioned.
>=Greater than equals toReturns value greater than the mentioned(including mentioned).
<=Less than equals to Returns value less than the mentioned(including mentioned).
!= Not equals toReturns value excluding mentioned.
BETWEENbetween operatorReturn the value between a certain range.
LIKElike operatorReturns the value if provided pattern is matched.
INin operatorTo specify multiple possible values for columns.

Leave a Comment

Your email address will not be published. Required fields are marked *