MySQL Error #1064 - Tiene un error en su sintaxis SQL; [cerrado]

A little help please! I really don't know what's going on here already. I have read a lot about this but there just seems to be nothing I can find wrong with this query:

INSERT INTO clients (water_bill_doc_url) VALUES ('client-uploads/01/water_bill.png') WHERE `client_id` = '74'

but still I keep getting this error:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE `client_id` = '74'' at line 1

if it helps, this clients table is InnoDB.

preguntado el 25 de agosto de 12 a las 03:08

2 Respuestas

INSERT INTO table (fields) VALUES (values) WHERE condition

Wait, what? Since when did INSERT permitir WHERE cláusulas?

You either want to do an UPDATE or put that client_id in the fields to insert.

Respondido 25 ago 12, 03:08

wow! lol! geez! never thought about that! sorry guys... mysql noob here.. it's just that I have never read that from anywhere.. my bad. - user1611778

An INSERT declaración no tiene WHERE clause, as it is for creating Un nuevo rows. We can assume you intended an UPDATE statement, since you wish to match an existing row:

SET water_bill_doc_url = 'client-uploads/01/water_bill.png' 
WHERE `client_id` = '74'

Lea las MySQL UPDATE referencia de sintaxis for full details on the syntax.

Respondido 25 ago 12, 03:08

thank you Mike! I really did not know what I was doing with the INSERT statement there.. geez! - user1611778

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.