Use LIMIT in SELECT : Limits : Select Clause SQL / MySQL


SQL / MySQL » Select Clause » Limits »

 

Use LIMIT in SELECT



/*

mysql> select * from Product;
+-----------+------------+----------------------+-------+
| ProductID | Name       | Description          | Price |
+-----------+------------+----------------------+-------+
|         1 | Java       | Java Demo Code       |     6 |
|         2 | Swing      | Swing Demo Code      |     7 |
|         3 | C#         | C# Demo Code         |     4 |
|         4 | JavaScript | JavaScript Demo Code |     3 |
|         5 | SQL        | SQL Demo Code        |     8 |
|         6 | Struts     | Struts Demo Code     |     9 |
+-----------+------------+----------------------+-------+
6 rows in set (0.00 sec)

mysql> /* Browse Products */
mysql> SELECT ProductID, Name
    -> FROM Product
    -> ORDER BY ProductID
    -> LIMIT 3,4;
+-----------+------------+
| ProductID | Name       |
+-----------+------------+
|         | JavaScript |
|         | SQL        |
|         | Struts     |
+-----------+------------+
rows in set (0.00 sec)


*/
/* Create Database */  
Drop TABLE Product;


CREATE TABLE Product (
    ProductID INT AUTO_INCREMENT NOT NULL PRIMARY KEY,
    Name VARCHAR(50NOT NULL,
    Description VARCHAR(255NOT NULL,
    Price DECIMAL NULL 
Type=InnoDB;
  
  
/* Insert Data */
INSERT INTO Product (Name, Description, PriceVALUES ('Java', 
                                                       'Java Demo Code',
                                                       5.99 );
INSERT INTO Product (Name, Description, PriceVALUES ('Swing', 
                                                       'Swing Demo Code',
                                                       6.99 );
INSERT INTO Product (Name, Description, PriceVALUES ('C#', 
                                                       'C# Demo Code',
                                                       3.99 );
INSERT INTO Product (Name, Description, PriceVALUES ('JavaScript', 
                                                       'JavaScript Demo Code',
                                                       2.99 );
INSERT INTO Product (Name, Description, PriceVALUES ('SQL', 
                                                       'SQL Demo Code',
                                                       7.99 );
INSERT INTO Product (Name, Description, PriceVALUES ('Struts', 
                                                       'Struts Demo Code',
                                                       8.99 );
select from Product;

/* Browse Products */
SELECT ProductID, Name
FROM Product 
ORDER BY ProductID
LIMIT 3,4;


           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

SQL / MySQL

 Navioo Select Clause
» Limits