Short answer: No need to wrap your *
in ticks - it can in fact be misleading, or cause errors by doing so.
From the MySQL manual,
The identifier quote character is the backtick (`)
This basically means that anything quoted with a backtick, is to be interpreted as a column or a table.
*
is an operator - not a table or a column. This operator basically says give me all the columns for this table. When you do...
`*`
..you are basically asking MySQL to grab you the value of a column with the exact name of *
, instead of using the actual operator *
which would give you all columns.
SELECT * FROM `myTable` -- Selects all columns
SELECT `*` FROM `myTable` -- Tries to select the column with the actual name of *
Obviously having a column named *
would be a very bad idea.
It's quite interesting, as something has changed between version 5.6 and 5.7 (see fiddles for MySQL 5.6 and MySQL 5.7), which allows for the following expression to be valid, although I wasn't able to find it documented anywhere.
SELECT `*` FROM `myTable`