This question already has an answer here:
hey guys was hoping you could help me out,
Not sure if I always had this problem or if its new, in phpmyadmin in the sql tab, the apostrophe it recognizes is different from what i type, for example,
when i type, it is
SELECT * FROM 'table'
this gives me an error, so instead I have to like copy/paste the inverted commas of some prebuilt query so that it looks like
SELECT * FROM `table`
see how the apostrophes are different? any way I can fix this?
also, i have seen many queries on the web, and i think even queries i call from php dont require table names to have apostrophes. But when write it in phpmyadmin, I can do queries without table names having apostrophes?
thanks in advance.
You should use ` in cases that your table/field name is a reserve word eg:
note that distinct is an sql command so you need to put the `.
table
here should be inside `.There are two different characters, the backtick and the single quote. Table and column names can be surrounded by the backtick, strings can be surrounded by quotes. There is nothign to fix :D
You dont need apostrophe on table name.
You should only need to quote table names when they conflict with a reserved word.
Also:
In MYSQL,
table
is a reserved keyword. If you want to use reserved keywords in mysql in query, you have to enclose them in backtick(`).As
table
is reserved keyword you query should beRegarding single quote ('), in mysql, it represents string value.
Demo