I’m going blind here… can’t seem to find the error in this SQL:
INSERT INTO sankt_groups_order (
parent_group_id,
child_group_id,
order
) VALUES (?,?,?)
ON DUPLICATE KEY UPDATE
order = ?
;
I am getting this error:
SQLSTATE[42000]: Syntax error or access violation:
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 'order ) VALUES ('65',NULL,'3') ON DUPLICATE KEY UPDATE order = '3''
Next will this SQL do what I think? I need it to insert the whole row if missing and update order if it exists… I have an index making parent_group_id and child_group_id unique.
orderis a reserved word in mysql, you’ll have to escape it:and yes, it should do what you think. If there’s a unique/primary key violation, you’ll only change the
orderfield.