

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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)
- Related Questions & Answers
- Fix MySQL ERROR 1064 (42000) check the manual that corresponds to your MySQL server version for the right syntax to use near ')'
- How to resolve the MySQL error “You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near?”
- MySQL LIMIT clause equivalent for SQL SERVER?
- How to fix error “You have an error in your syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near… ”?
- Resolve usage of quotes ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use?
- How to write a MySQL “LIMIT” in SQL Server?
- Fix MySQL Error #1064 - You have an error in your SQL syntax… near 'TYPE=MyISAM?
- Difference between MySQL and SQL Server
- How can I check the version of MySQL Server?
- MySQL LIMIT to select a single row
- Resolve Syntax error near “ORDER BY order DESC” in MySQL?
- MySQL query to select top 10 records?
- The equivalent of SQL Server function SCOPE_IDENTITY() in MySQL?
- How to select last 10 rows from MySQL?
- Equivalent of SQL Server IDENTITY Column in MySQL?