What do the `s around table/field names in SQL mean?
Here's an SQL statement that phpMyAdmin generated for me:
SELECT * FROM `table_name` WHERE 1
You can see that table_name
is surrounded by ` characters.
Why?开发者_Go百科
It's used to enclose identifiers in MySQL.
It lets them have characters that would be ambiguous or otherwise invalid in normal SQL, such as a space:
`foo bar` - is a valid MySQL identifier
foo bar - is not, since foo is the identifier, and bar is ambiguous
Its used as to escape/enclose characters, in case of a space or some other illegal character in the table or field name.
From the docs:
If an identifier contains special characters or is a reserved word, you must quote it whenever you refer to it. The set of alphanumeric characters from the current character set, “_”, and “$” are not special. Reserved words are listed at Section 8.3, “Reserved Words”.
http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
精彩评论