0

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'

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

Comments

1

You're using the wrong quotes for the values. Use simple quotes ' to indicate a char value.

Comments

0

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"));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.