Tip of the day: Use backticks
, like a boss! Even in your handwriting!
Update: If you take the above advice, you don't need to read the following anymore! Seriously!
Question:
I'm a little bit annoyed by this. I can create a table containing columns which are named key
and value
, but when I want to work with these columns I will see a very nice syntax error explaining that these are reserved keywords
for MySQL.
My question is: does anybody know why it is like this? Why I'm not receiving the syntax error in the first place? Is it backed by any reason?
Only KEY
is a reserved keyword :D
.
just wrap the column name KEY
with backtick so you can use it, eg
SELECT `key`
FROM tableName
or supply the table with alias,
SELECT a.key
FROM tableName a
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With