MySQL – Benefits of Using Backticks in Queries

MySQLselect

In MySQL we can create queries with or without the backtick (`) symbol. Example:

  1. SELECT * FROM TEST;
  2. SELECT * FROM `TEST`;

Both works fine in mysql-console.

Is there any technical difference between them?

Is there any benefit using (`) over over simple queries?

Best Answer

They are called quoted identifiers and they tell the parser to handle the text between them as a literal string. They are useful for when you have a column or table that contains a keyword or space. For instance the following would not work:

CREATE TABLE my table (id INT);

But the following would:

CREATE TABLE `my table` (id INT);

Also, the following would get an error, because COUNT is a reserved keyword:

SELECT count FROM some_table

But the following would be parsed correctly:

SELECT `count` FROM some_table

I hope this helps you.