Home >Database >Mysql Tutorial >When Should Backticks (`) Be Used in SQL Queries?
SQL Backticks (`): Usage and Best Practices
The backtick (`) character isn't part of standard SQL syntax. However, several database systems (DBMS) utilize it for escaping identifiers (column and table names).
Identifier Escaping
The SQL standard suggests using double quotes (") for identifier delimiters:
<code class="language-sql">SELECT "select" FROM "from" WHERE "where" = "group by";</code>
But MySQL, for instance, offers backticks as an alternative:
<code class="language-sql">SELECT `select` FROM `from` WHERE `where` = `group by`;</code>
Microsoft SQL Server employs square brackets ([]):
<code class="language-sql">SELECT [select] FROM [from] WHERE [where] = [group by];</code>
When Escaping is Necessary
Ideally, avoid identifier escaping. Quoting becomes necessary when:
Case Sensitivity
Remember that escaped identifiers are case-sensitive. "from" and "FROM" usually represent distinct columns.
Further Considerations
The above is the detailed content of When Should Backticks (`) Be Used in SQL Queries?. For more information, please follow other related articles on the PHP Chinese website!