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

LIMIT:

Limit is used to limit the result returned by the SELECT query. The below query will return all records in the mobile sales table


select * from mobile_sales_details

mobile_name             type        price       discount    sold_count  brand_name  os_name                   added_date  sim_type    primary_camera_pixel
----------------------  ----------  ----------  ----------  ----------  ----------  ------------------------  ----------  ----------  --------------------
Moto X (16 GB) (Black)  Smartphone  23999                   19526       Motorola    Android v4.4 (KitKat) OS  2014-03-19  Single      10                  
Moto G (Black  with 16  Smartphone  13999                   181257      Motorola    Android v4.4 (KitKat) OS  2014-03-19  Dual        5                   
Moto E (Black)          Smartphone  6999                    125122      Motorola    Android v4.4 (KitKat) OS  2014-03-19  Dual        5                   
Asus Zenfone 4 A400CG   Smartphone  5999                    2168        Asus        Android v4.3 OS           2014-07-12  Dual        5                   
Asus Zenfone 5 A501CG   Smartphone  9999                    4814        Asus        Android v4.3 OS           2014-07-11  dual        8                   
Asus Zenfone 5 A501CG   Smartphone  12999                   1305        Asus        Android v4.3 OS           2014-07-11  Dual        8                   
Asus Zenfone 6 A600CG   Smartphone  16999                   784         Asus        Android v4.3 OS           2014-07-11  Dual        13                  
Alcatel Onetouch Idol   Smartphone  16999                   3840        Alcatel     Android v4.2 (Jelly Bean  2014-07-12  Dual        13.1                
Samsung Galaxy S Duos   Smartphone  8206                    13150       Samsung     Android v4.2 (Jelly Bean  2014-07-10  Dual        5                   
Samsung Galaxy Star Pr  Smartphone  7599        23          6064        Samsung     Android v4.2 (Jelly Bean  2014-07-10  Dual        2                   
Samsung Galaxy S Duos   Smartphone  8214                    13150       Samsung     Android v4.2 (Jelly Bean  2014-07-10  Dual        5                   
Samsung Galaxy Core I8  Smartphone  11795                   7932        Samsung     Android v4.1 OS           2014-07-10  Dual        5                   
Samsung Galaxy Grand 2  Smartphone  18990                   5023        Samsung     Android v4.3 OS           2014-07-10  Dual        8                   
Samsung Galaxy Trend S  Smartphone  9610        28          3099        Samsung     Android v4.2 (Jelly Bean  2014-03-19  Dual        3                   
Samsung Galaxy Grand N  Smartphone  14010                   1060        Samsung     Android v4.2 (Jelly Bean  2014-03-19  Dual        5                   
Samsung I8552 - Galaxy  Smartphone  15999                   7846        Samsung     Android v4.1 OS           2014-07-12  Dual        5                   
Samsung Galaxy S4 Mini  Smartphone  24730       26          3289        Samsung     Android v4.2 (Jelly Bean  2014-04-23  Dual        8                   
Samsung GT 1200 R/I/M   Ordinary    1299        17          141         Samsung                               2014-03-19  Single                          
Samsung Guru 1200 (Bla  Ordinary    1399        9           6566        Samsung                               2014-07-10  Single    

...etc

but if you want to return only ten rows from the list use limit like below


select * from mobile_sales_details limit 10

mobile_name             type        price       discount    sold_count  brand_name  os_name                   added_date  sim_type    primary_camera_pixel
----------------------  ----------  ----------  ----------  ----------  ----------  ------------------------  ----------  ----------  --------------------
Moto X (16 GB) (Black)  Smartphone  23999                   19526       Motorola    Android v4.4 (KitKat) OS  2014-03-19  Single      10                  
Moto G (Black  with 16  Smartphone  13999                   181257      Motorola    Android v4.4 (KitKat) OS  2014-03-19  Dual        5                   
Moto E (Black)          Smartphone  6999                    125122      Motorola    Android v4.4 (KitKat) OS  2014-03-19  Dual        5                   
Asus Zenfone 4 A400CG   Smartphone  5999                    2168        Asus        Android v4.3 OS           2014-07-12  Dual        5                   
Asus Zenfone 5 A501CG   Smartphone  9999                    4814        Asus        Android v4.3 OS           2014-07-11  dual        8                   
Asus Zenfone 5 A501CG   Smartphone  12999                   1305        Asus        Android v4.3 OS           2014-07-11  Dual        8                   
Asus Zenfone 6 A600CG   Smartphone  16999                   784         Asus        Android v4.3 OS           2014-07-11  Dual        13                  
Alcatel Onetouch Idol   Smartphone  16999                   3840        Alcatel     Android v4.2 (Jelly Bean  2014-07-12  Dual        13.1                
Samsung Galaxy S Duos   Smartphone  8206                    13150       Samsung     Android v4.2 (Jelly Bean  2014-07-10  Dual        5                   
Samsung Galaxy Star Pr  Smartphone  7599        23          6064        Samsung     Android v4.2 (Jelly Bean  2014-07-10  Dual        2                   

The above query returns only the first ten records from the table,remaining rows are skipped. And if you need to get rows from 10 to 20 ,use limit 10,10


select * from mobile_sales_details limit 10,10

mobile_name                            type        price       discount    sold_count  brand_name  os_name                    added_date  sim_type    primary_camera_pixel
-------------------------------------  ----------  ----------  ----------  ----------  ----------  -------------------------  ----------  ----------  --------------------
Samsung Galaxy S Duos 2 S7582 (Black)  Smartphone  8214                    13150       Samsung     Android v4.2 (Jelly Bean)  2014-07-10  Dual        5                   
Samsung Galaxy Core I8262 (Chic White  Smartphone  11795                   7932        Samsung     Android v4.1 OS            2014-07-10  Dual        5                   
Samsung Galaxy Grand 2 (Black)         Smartphone  18990                   5023        Samsung     Android v4.3 OS            2014-07-10  Dual        8                   
Samsung Galaxy Trend S7392 (Midnight   Smartphone  9610        28          3099        Samsung     Android v4.2 (Jelly Bean)  2014-03-19  Dual        3                   
Samsung Galaxy Grand Neo GT-I9060 (Wh  Smartphone  14010                   1060        Samsung     Android v4.2 (Jelly Bean)  2014-03-19  Dual        5                   
Samsung I8552 - Galaxy Grand Quattro   Smartphone  15999                   7846        Samsung     Android v4.1 OS            2014-07-12  Dual        5                   
Samsung Galaxy S4 Mini I9192 (White F  Smartphone  24730       26          3289        Samsung     Android v4.2 (Jelly Bean)  2014-04-23  Dual        8                   
Samsung GT 1200 R/I/M                  Ordinary    1299        17          141         Samsung                                2014-03-19  Single                          
Samsung Guru 1200 (Black)              Ordinary    1399        9           6566        Samsung                                2014-07-10  Single                          
Samsung Galaxy S5 (Charcoal Black)     Smartphone  54300       30          5696        Samsung     Android v4.4 (KitKat) OS   2014-07-10  Single      16

The same concept can be achieved by using the offset keyword like limit 10 offset 10


select * from mobile_sales_details limit 10 offset 10

If you want to get low cost mobile in samsung use the order by keyword to sort the result and limit it by 1


select price from mobile_sales_details where brand_name='Samsung' order by price limit 1

price

------------

1299