SQL WHERE Clause

0
154

sqltuts

SQL WHERE clause is an optional clause used to define what records are to be included in the query. We use conditional operators like <, >, =, >=, <=, !=(<>) , BETWEEN a AND b, IN(list) etc.

Syntax:

For example we have a table, Employee:

Employee_id First_name Last_name sex
123 Mack Johnson male
124 Jack Obama male
125 Queen Khan female

 

Now, if we want to select the first name and employee_id of only the ones who are males:

This will give the following result:

Employee_id First_name
123 Mack
124 Jack

 

For strings , we always enclose them in single quotes.

Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.