General Note:

Here we have pulled in the data from a sample database. You can download it from the following link and use it for practicing Click Here For Sample Database

This is logic table for Boolean operation. Consider 1 as true and 0 as false in the below table

A B A and B A or B Not A Not b
0 0 0 0 1 1
0 1 0 1 1 0
1 0 0 1 0 1
1 1 1 1 0 0

AND:

AND operator is used to filter the records. If both the conditions are true, it will return the record. If any one condition fails, it will not return any record If you want to display mobiles list, whose brand name must be Samsung and their price must be greater than 10000


Select mobile_name,price ,brand_name from mobile_sales_details where price>10000 and brand_name =’Samsung’

mobile_name                             price       brand_name
--------------------------------------  ----------  ----------
Samsung Galaxy Core I8262 (Chic White)  11795       Samsung
Samsung Galaxy Grand 2 (Black)          18990       Samsung
Samsung Galaxy Grand Neo GT-I9060 (Whi  14010       Samsung
Samsung I8552 - Galaxy Grand Quattro    15999       Samsung
Samsung Galaxy S4 Mini I9192 (White Fr  24730       Samsung
Samsung Galaxy S5 (Charcoal Black)      54300       Samsung
Samsung Galaxy S4 I9500 (White Frost)   28071       Samsung
Samsung Galaxy S3 (Marble White  with   31850       Samsung
Samsung Galaxy Grand Duos I9082         19000       Samsung

 

OR Operator:

If you want to display mobiles list, whose brand name is Samsung or their price greater than 10000


Select mobile_name,price ,brand_name from mobile_sales_details where price>10000 or  brand_name =’Samsung’
mobile_name             price       brand_name
----------------------  ----------  ----------
Moto X (16 GB) (Black)  23999       Motorola
Moto G (Black  with 16  13999       Motorola
Asus Zenfone 5 A501CG   12999       Asus
Asus Zenfone 6 A600CG   16999       Asus
Alcatel Onetouch Idol   16999       Alcatel
Samsung Galaxy S Duos   8206        Samsung
Samsung Galaxy Star Pr  7599        Samsung
Samsung Galaxy S Duos   8214        Samsung
Samsung Galaxy Core I8  11795       Samsung
Samsung Galaxy Grand 2  18990       Samsung
Samsung Galaxy Trend S  9610        Samsung
Samsung Galaxy Grand N  14010       Samsung
Samsung I8552 - Galaxy  15999       Samsung
Samsung Galaxy S4 Mini  24730       Samsung