What is the difference between single quotes and backticks in MySQL?

WBOY
Release: 2016-08-22 10:12:55
Original
1305 people have browsed it

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.

Reply content:

Pay attention to study.

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 ("`"):

MySQL :: MySQL 5.5 Reference Manual :: 9.2 Schema Object Names

A string is a sequence of bytes or characters, enclosed within either single quote (“'”) or double quote (""") characters
MySQL :: 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.
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template