Home > Article > Backend Development > What is the difference between single quotes and backticks in MySQL?
I used to use single quotes when creating tables and queries in MySQL, but later I found that there was a problem. My classmates reminded me to use backticks. Recently I found that backticks can also cause problems:
1.
2.
I saw it on the Internet It is said that the backticks are to distinguish MySQL's reserved words from ordinary characters. In this case, the second one can be explained, but why is the first one?
In fact, what is the actual difference between single quotes and backticks? How does MySQL operate on these two symbols?
Please help me, thank you.
Certain objects within MySQL, including database, table, index, column, alias, view, stored procedure, partition, tablespace, and other object names are known as identifiers
An identifier may be quoted or unquoted. If an identifier contains special characters or is a reserved word, you must quote it whenever you refer to it.
The identifier quote character is the backtick ("`"):
A string is a sequence of bytes or characters, enclosed within either single quote (“'”) or double quote (""") charactersMySQL :: MySQL 5.5 Reference Manual :: 9.1.1 String Literals The simplest way to avoid errors is to use backticks for reserved words such as table names, and double quotes for other reserved words such as SQL statements. I usually try not to use single quotes. To put it simply, use single quotes for strings and backticks for table names, field names, etc.