In MySql queries, table and column names should be quoted with `backticks`, and text values should be quoted with 'single' or "double" quotes. MySql allows you to be lazy and omit the quotes, as we sometimes do in this guide. But you can't always omit them. Sometimes, queries won't work without them. Let's say we have a table with column called "table". This query will return a syntax error because 'table' is a reserved word:
SELECT table, name FROM my_table
In this case you must write:
SELECT `table`, `name` FROM `my_table`
Sometimes, a query might appear to work, but does not return the results you might be expecting. Let's say we have a table of annual sales results with columns "month_txt", "2017", "2018", "2019", "2020". This query will execute successfully:
SELECT month_txt, 2020 FROM my_table
But it won't give you the values of the 2020 column. It will return the literal numeric value 2020... January, 2020 February, 2020 March, 2020
To clarify that 2020 is a column name, you must use the backticks:
SELECT `month_txt`, `2020` FROM `my_table`
It's good practice to always use backticks for table and column names, and normal quotes for text values.