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

NOT Operator:

NOT operator is used to get reverse result. It is not independent operator. It works only with BETWEEN...AND.., IS NULL, LIKE and IN. If you want to get mobile list, whose price less than 5000 and greater than 12000


Select mobile_name,price ,brand_name from mobile_sales_details where price not between 5000 and 12000

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 Grand 2  18990       Samsung   
Samsung Galaxy Grand N  14010       Samsung   
Samsung I8552 - Galaxy  15999       Samsung   
Samsung Galaxy S4 Mini  24730       Samsung   
Samsung GT 1200 R/I/M   1299        Samsung   
Samsung Guru 1200 (Bla  1399        Samsung   
Samsung Galaxy S5 (Cha  54300       Samsung   
Samsung Galaxy S4 I950  28071       Samsung   
Samsung Guru E1207T (B  1450        Samsung   
Samsung Galaxy S3 (Mar  31850       Samsung   
Samsung Galaxy Grand D  19000       Samsung   
Nokia 105 (Black)       1249        Nokia     
Nokia Lumia 1320 (Blac  17190       Nokia     

If you want to get the mobile list other than Samsung and Sony


Select mobile_name,price,brand_name from mobile_sales_details where brand_name not in (‘Sony’,’Samsung’)
mobile_name             price       brand_name
----------------------  ----------  ----------
Moto X (16 GB) (Black)  23999       Motorola  
Moto G (Black  with 16  13999       Motorola  
Moto E (Black)          6999        Motorola  
Asus Zenfone 4 A400CG   5999        Asus      
Asus Zenfone 5 A501CG   9999        Asus      
Asus Zenfone 5 A501CG   12999       Asus      
Asus Zenfone 6 A600CG   16999       Asus      
Alcatel Onetouch Idol   16999       Alcatel   
Nokia Lumia 520 (Black  11289       Nokia     
Nokia 105 (Black)       1249        Nokia     
Nokia Lumia 630 Dual S  9479        Nokia     
Nokia XL (Bright Orang  11999       Nokia     
Nokia Lumia 1320 (Blac  17190       Nokia     
Nokia 206 (Black  with  3689        Nokia     
Nokia Lumia 625 (Black  16500       Nokia     
Nokia 220 (Black)       3299        Nokia     
Apple iPhone 5S (Gold   43199       Apple     

Find out which brand name not starts with the letter S


Select brand_name from mobile_sales_details where brand_name not like ‘S%’

brand_name
----------
Motorola  
Motorola  
Motorola  
Asus      
Asus      
Asus      
Asus      
Alcatel   
Nokia     
Nokia     
Nokia     
Nokia     

Find out ,whose brand name don’t have the letter A at place


Select brand_name from mobile_sales_details where brand_name not like ‘%A%’

brand_name
----------
Sony      
Sony      
Sony      
Sony      
Sony      
Lenovo    
Lenovo    
Lenovo    
Lenovo    
Lenovo    

If you want to find out which mobile do not have null as discount


Select mobile_name,price,discount from mobile_sales_details where discount is not null

mobile_name                            price       discount  
-------------------------------------  ----------  ----------
Samsung Galaxy Star Pro S7262 (White)  7599        23        
Samsung Galaxy Trend S7392 (Midnight   9610        28        
Samsung Galaxy S4 Mini I9192 (White F  24730       26        
Samsung GT 1200 R/I/M                  1299        17        
Samsung Guru 1200 (Black)              1399        9         
Samsung Galaxy S5 (Charcoal Black)     54300       30        
Samsung Guru E1207T (Black)            1450        0.99      
Samsung Galaxy S3 (Marble White  with  31850       35        
Samsung Galaxy Grand Duos I9082        19000       10        
Nokia Lumia 520 (Black)                11289       29        
Nokia 105 (Black)                      1249        7         
Nokia XL (Bright Orange)               11999       14        
Nokia Lumia 625 (Black)                16500       7         
Nokia 220 (Black)                      3299        14        
Apple iPhone 5C (Blue  with 16 GB)     41900       14