SQL WHERE Clause

0
205

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.

Previous articleSQL INSERT INTO Statement
Next articleSQL LIKE Clause
Hello Itsourcecoders, welcome to itsourcecode.com. I'm Joken Villanueva, MIT a passionate Blogger, Programmer and a Hobbyist. I started Itsourcecode because I wanted to give back and Share all the learnings and knowledge I've learned in my career and I believe through this website I would be able to help and assist those newbie programmers in enhancing their skills from different programming languages. So let us all help each other by sharing our ideas!

Leave a Reply

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