
- 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
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?â
To avoid this type of error in MySQL stored procedure, you need to change the delimiter ; to //.
Suppose if you are using stored procedure or triggers or even function then you need to change the delimiter. The syntax is as follows.
DELIMITER // CREATE PROCEDURE yourProcedureName() BEGIN Statement1, . . N END; // DELIMITER ;
To understand the above syntax, let us create a stored procedure. The query to create a stored procedure is as follows -
mysql> DELIMITER // mysql> CREATE PROCEDURE sp_getAllRecords() -> BEGIN -> SELECT *FROM employeetable; -> END; -> // Query OK, 0 rows affected (0.23 sec) mysql> DELIMITER ;
Call the stored procedure using CALL command. The syntax is as follows.
CALL yourStoredProcedureName();
Now call the above procedure that returns all records of Employee table. The query is as follows.
mysql> CALL sp_getAllRecords();
The following is the output.
+------------+--------------+----------------+ | EmployeeId | EmployeeName | EmployeeSalary | +------------+--------------+----------------+ | 2 | Bob | 1000 | | 3 | Carol | 2500 | +------------+--------------+----------------+ 2 rows in set (0.00 sec) Query OK, 0 rows affected (0.02 sec)
- Related Articles
- 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?
- Fix MySQL ERROR 1064 (42000) check the manual that corresponds to your MySQL server version for the right syntax to use near ')'
- Resolve MySQL ERROR 1064 (42000): You have an error in your syntax?
- Fix MySQL Error #1064 - You have an error in your SQL syntax⊠near 'TYPE=MyISAM?
- MySQL server version for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=10'?
- ERROR 1064 (42000): You have an error in your SQL syntax at zero fill column?
- Resolve Syntax error near âORDER BY order DESCâ in MySQL?
- Declare syntax error in MySQL Workbench?
- MySQL syntax error (in SELECT query) while using âgroupâ as table name
- Resolve the MySQL error 'TYPE=MyISAM'?
- What is the MySQL syntax error in this query â Creating a table with reserved keyword?
- Fix Error in MySQL syntax while creating a table column with name âindexâ?
- How can I check the version of MySQL Server?
- How to raise an error within MySQL?

Advertisements