
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
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 Articles
- Fix MySQL ERROR 1064 (42000) check the manual that corresponds to your MySQL server version for the right syntax to use near ')'
- 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… ”?
- How to resolve the MySQL error “You have an error in your SQL syntax; check the manual\nthat 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 can I check the version of MySQL Server?
- Resolve Syntax error near “ORDER BY order DESC” in MySQL?
- Command Options for Connecting to the MySQL Server
- How To Enable 64-bit Version Option in VirtualBox?
- Using Option Files for MySQL programs? Usage of Option Files
- What is the use of ‘c’ option while writing MySQL statements?
- Fix MySQL Error #1064 - You have an error in your SQL syntax… near 'TYPE=MyISAM?
- What is the correct syntax for NOT LIKE in MySQL?
- How To Check MySQL Version
- MySQL LIMIT clause equivalent for SQL SERVER?
- MySQL Syntax to create Foreign Key?
