- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MySQL server version for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=10'?
You can use SET command, but SET OPTIOn deprecated. Therefore, use SET SQL_SELECT_LIMIT.
The syntax is as follows −
SET SQL_SELECT_LIMIT=yourIntegerValue;
To understand the above syntax, let us create a table. The query to create a table is as follows −
mysql> create table MySQLSelectDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY -> ); Query OK, 0 rows affected (0.99 sec)
Insert some records in the table using insert command. The query is as follows −
mysql> INSERT INTO MySQLSelectDemo VALUES(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(),(); Query OK, 37 rows affected (0.20 sec) Records: 37 Duplicates: 0 Warnings: 0
Display all records from the table using select statement. The query is as follows −
mysql> SELECT *FROM MySQLSelectDemo;
Here is the output −
+----+ | Id | +----+ | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 10 | | 11 | | 12 | | 13 | | 14 | | 15 | | 16 | | 17 | | 18 | | 19 | | 20 | | 21 | | 22 | | 23 | | 24 | | 25 | | 26 | | 27 | | 28 | | 29 | | 30 | | 31 | | 32 | | 33 | | 34 | | 35 | | 36 | | 37 | +----+ 37 rows in set (0.00 sec)
Here is the query to set sql_select_limit
Case 1 − The query is as follows −
mysql> SET SQL_SELECT_LIMIT=3; Query OK, 0 rows affected (0.00 sec)
Now check the records of table. After implementing the above query, you will get only 3 records.
The query is as follows −
mysql> SELECT *FROM MySQLSelectDemo;
The output −
+----+ | Id | +----+ | 1 | | 2 | | 3 | +----+ 3 rows in set (0.00 sec)
Case 2 − Here is the query to set sql_select_limit
The query is as follows −
mysql> SET SQL_SELECT_LIMIT=10; Query OK, 0 rows affected (0.00 sec)
Now check the records of table.After implementing the above query, you will get only 10 records. The query is as follows −
mysql> SELECT *FROM MySQLSelectDemo;
The output is as follows −
+----+ | Id | +----+ | 1 | | 2 | | 3 | | 4 | | 5 | | 6 | | 7 | | 8 | | 9 | | 10 | +----+ 10 rows in set (0.00 sec)