Wednesday, 16 November 2016

mysql - Unknown column '0' in 'field list'?




I have the following MySQL query:



INSERT INTO ipi_messages (Message_userID, Message_fromName, Message_fromEmail, Message_subject, Message_body) VALUES(`0`, `hope`, `thisworks@gmail.com`, `i hope`, `this works`)



My database schema is:



enter image description here



I cannot, for the life of me, figure out how that error is even possible. Why would MySQL try to find 0 as one of the columns? It is clearly not even in the column declaration piece of the code.



So why am I getting the error Unknown column '0' in 'field list'?


Answer




You need to use regular quotes ' for string values. Backquotes are used to enclose column and table names.


No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...