Jeroen Bellemans Jeroen Bellemans - 6 months ago 14
SQL Question

Update query does not update row(s)

I'm struggling with a very basic query. I can not see what I'm doing wrong.

Here is the first query I tried:

UPDATE `qrm_logs` SET `billable` = '0' AND `invoice_id` = NULL WHERE `id` = '842'


And the second:

UPDATE `qrm_logs` SET `billable` = 0 AND `invoice_id` IS NULL WHERE `id` = '842'


Column
billable
has type
enum
. Column
invoice_id
is an
int
type. Also, invoice_id can be nullable.

What causes this problem?

Answer

Should be:

UPDATE `qrm_logs` SET `billable` = 0, `invoice_id` = NULL WHERE `id` = 842

note the comma instead of the AND.