Home >Database >Mysql Tutorial >When and How Should I Use Backticks in SQL?
Usage of backtick (`) in SQL
Although the backtick (`) is widely used, it has no special meaning in the SQL standard.
Identifier reference
The SQL standard requires the use of double quotes to quote identifiers:
<code class="language-sql">SELECT "select" FROM "from" WHERE "where" = "group by";</code>
MySQL Usage
In MySQL, backticks can be used as an alternative to double quotes to quote identifiers:
<code class="language-sql">SELECT `select` FROM `from` WHERE `where` = `group by`;</code>
Other databases
Various databases handle identifier references differently:
[]
When to quote identifiers
Normally, identifiers should not be quoted unless absolutely necessary. Some common scenarios that require citation include:
Quotation usage of values and field names
Values must always be enclosed in single quotes:
<code class="language-sql">SELECT * FROM table WHERE field = 'value';</code>
Field names can be enclosed in double or single quotes, but this is not mandatory:
<code class="language-sql">SELECT "field" OR field FROM table;</code>
The above is the detailed content of When and How Should I Use Backticks in SQL?. For more information, please follow other related articles on the PHP Chinese website!