I have the following structure
user_id int(11)
right int(11)
group_id int(11)
value tinyint(1)
And 3 queries
INSERT INTO user_rights (`user_id`,`right`,`group_id`,`value`)
VALUES ( '42', '160', '1', '1' );
INSERT INTO user_rights ('user_id','right','group_id','value')
VALUES ( '42', '160', '1', '1' );
INSERT INTO user_rights (user_id,right,group_id,value)
VALUES ( '42', '160', '1', '1' );
Explain me WHYYYY only the first works????
I have all my life used the third one!
Answer
RIGHT is a mySQL reserved word. It will work only when wrapped in backticks.
When you're not using reserved words, it will work without the backticks, as well.
The second way will never work because quotes are used to quote strings, but never database, table or column identifiers.
No comments:
Post a Comment