SQL AND & OR Operators

0
192

sqltuts

We can link multiple WHERE statements by AND/OR statements.

AND means that all the conditions are TRUE.

OR means, at least, one condition is TRUE.

 

For example, consider the following table Employee:

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

 

Example of using AND:

 

This will give the following result:

First_name
Mack

Example of using OR

First_name
Mack
Jack

 

In this case, we see two names as one condition (sex=’male’) for them is true.

Example of using AND & OR

This will give the following output:

First_name
Mack
Jack

 

Uses of AND OR in different aspects

 

 

 

Facebook Comments
Previous articleSQL ALTER Table Statement
Next articleSQL Join Command
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.