
- 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
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?
In MySQL, you can use two different types of quotation marks which is backtick and another is single quotes or double quotes. In this case, maybe you are using single quotes to the column name that’s why you are getting error. You need to use the backtick symbol (` `) instead of single quotes. Backtick can be used with column names while single quotes can be used for strings.
To understand the above error, let us create a table. The query to create a table is as follows −
mysql> create table Backtick_SymbolDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Name varchar(20), -> FileName varchar(30), -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.81 sec)
The error occurs if we use single quotes instead of backtick symbol around the column as shown below. Here, we have inserted a value with single quotes and the error is visible −
mysql> insert into Backtick_SymbolDemo(`Name`,'FileName') values('John','Sum.cpp'); 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 near ''FileName') values('John','Sum.cpp')' at line 1
To avoid this error either use the backtick symbol around the all column name or do not use both the backtick or single quotes.
The query to insert record is as follows. Here is the use of the backtick symbol around both column name.
mysql> insert into Backtick_SymbolDemo(`Name`,`FileName`) values('John','Sum.cpp'); Query OK, 1 row affected (0.12 sec)
Here is the insert record without using the backtick symbol. The query is as follows −
mysql> insert into Backtick_SymbolDemo(Name,FileName) values('Larry','SocketProgram.java'); Query OK, 1 row affected (0.23 sec) mysql> insert into Backtick_SymbolDemo(Name,FileName) values('Mike','UserCreationScript.sql'); Query OK, 1 row affected (0.10 sec)
Display all records from the table using a select statement. The query is as follows −
mysql> select *from Backtick_SymbolDemo;
The following is the output −
+----+-------+------------------------+ | Id | Name | FileName | +----+-------+------------------------+ | 1 | John | Sum.cpp | | 2 | Larry | SocketProgram.java | | 3 | Mike | UserCreationScript.sql | +----+-------+------------------------+ 3 rows in set (0.00 sec)
- Related Articles
- 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?”
- 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… ”?
- 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?
- ERROR 1064 (42000): You have an error in your SQL syntax at zero fill column?
- Fix MySQL Error #1064 - You have an error in your SQL syntax… near 'TYPE=MyISAM?
- Resolve ERROR 1064 (42000) that occurred after using varchar (without providing the size)
- MySQL server version for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=10'?
- Resolve Syntax error near “ORDER BY order DESC” in MySQL?
- Declare syntax error in MySQL Workbench?
- Fix ERROR 1064 (42000) while creating a database in MySQL?
- How to resolve the ERROR 1115 (42000): Unknown character set: 'utf8mb4'?
- Fix MySQL Database Error #1064?
- How to correctly use INSERT INTO … SELECT in MySQL to avoid Error 1064?
- MySQL syntax error (in SELECT query) while using ‘group’ as table name
