Categories
Sql Server

How to use AND & OR in Sql server

Both AND & OR are used to filter records on more than one condition.

AND & OR

AND operator displays a records if  first condition and second condition is true.

OR operator displays a records if either first condition or second condition is true.
 Example Table:-

ID Name Class Roll No
1 Jai B.A 12
2 Mohan M.A 23
4 Om B.A 2

AND Statement Example:-

Select * from example where name='jai' and class='b.a'

Result:-

ID Name Class Roll No
1 Jai B.A 12

OR Statement Example:-

Select * from example where name='jai' or name='om'

Result:-

ID Name Class Roll No
1 Jai B.A 12
4 Om B.A 2