Reputation: 2067
My database table has columns email, username and password. I'm trying to insert these test values into them, but the query seems to be interpreting the value for the test email in a strange way. What's wrong with this query?
mysql> INSERT INTO `tbl_user`
-> (`email`, `username`, `password`)
-> VALUES
-> (`[email protected]`, `Test_User_One`, MD5(`test1`)),
-> (`[email protected]`, `Test_User_Two`, MD5(`test2`))
-> ;
ERROR 1054 (42S22): Unknown column '[email protected]' in 'field list'
Upvotes: 0
Views: 1023
Reputation: 385104
Backticks delimit field names (database names, table names or column names).
Use single or double quotes to delimit strings:
INSERT INTO `tbl_user` (`email`, `username`, `password`)
VALUES ("[email protected]", "Test_User_One", MD5("test1")),
("[email protected]", "Test_User_Two", MD5("test2"));
Upvotes: 0
Reputation: 116100
You're using the wrong quotes for the values. Use simple quotes '
to indicate a char value.
Upvotes: 1
Reputation: 596
Try using single quotes rather than backticks round the values, i.e.
mysql> INSERT INTO `tbl_user`
-> (`email`, `username`, `password`)
-> VALUES
-> ('[email protected]', 'Test_User_One', MD5('test1')),
-> ('[email protected]', 'Test_User_Two', MD5('test2'))
-> ;
Backticks are used to signify column names whereas single(or double) quotes will be used as a value.
Upvotes: 5