MySQL Where Clause

A WHERE Clause is an SQL query to apply a filter on the rows retrieved.
When a WHERE Clause is added to MySQL query, the MySQL engine compares each record in the table with the condition specified in the WHERE Clause.The MySQL engine display only those records that satisfy the specified condition.
Syntax:

SELECT * FROM tablename where condition;

MySQL table(tblemployee)

id Emp_Name Emp_Code Emp_Designation Emp_joinnig_date
1 Anuj Kumar 10806121 Software Developer 2018-02-01
1 Sanjeev Kumar 10806860 Software Testing 2015-10-15
1 Rahul Singh 10806865 HR 2016-12-22
1 John Doe 13406121 Accountant 2019-03-01

Ex:

Select Emp_Name  from tblemployee where id=1;

Output
Anuj Kumar
Operators in the where clause :
 

Operator Description
= Equality
!= Inequality
< Less than
<= Less than or equal
> More than
>= More than or equal
Between min Within the range
AND max min to max
IS NULL Is a NULL Value
IS NOT NULL Is not a null value

Comparison operators are used in a query with a WHERE clause to test if a specified condition is met. When the evaluation is TRUE the query will return the data, otherwise nothing will be returned.
MySQL 5.6 reference manual online at dev.mysql.com/doc

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Privacy & Cookies Policy