tags:

views:

58

answers:

1

What's the difference between

SELECT * FROM `this`

and

SELECT * FROM this

?

+7  A: 

The former is escaped, the latter isn't. Consider:

SELECT * FROM `FROM`

On systems where the the backtick is an escape, that would select from a table called FROM (whereas without the backticks, it's a syntax error). Some systems use square brackets instead, e.g., SELECT * FROM [FROM].

T.J. Crowder
so basically, you should never have a field called FROM but only `FROM`, is that right?
sombe
@Gal: Right. And it'll depend on your platform whether you use backticks for that or some other notation (I've just updated the answer with a bit more detail).
T.J. Crowder
@James Curran: Thanks, I *just* saw that and went to edit, and you'd beaten me to it!
T.J. Crowder