2

What's the difference between

SELECT * FROM `this`

and

SELECT * FROM this

?

John Y
  • 14,123
  • 2
  • 48
  • 72
Gal
  • 23,122
  • 32
  • 97
  • 118

1 Answers1

8

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].

James Curran
  • 101,701
  • 37
  • 181
  • 258
T.J. Crowder
  • 1,031,962
  • 187
  • 1,923
  • 1,875
  • so basically, you should never have a field called FROM but only `FROM`, is that right? – Gal Feb 13 '10 at 13:22
  • @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 Feb 13 '10 at 13:23
  • @James Curran: Thanks, I *just* saw that and went to edit, and you'd beaten me to it! – T.J. Crowder Feb 13 '10 at 13:25