MYSQL, multiple insert and ON DUPLICATE UPDATE -
i'm blocked multiple insert values , if 1 exist, custom update. here query not work :
insert `table` (f1,f2,status) values (1,5,'on') on duplicate key update status='off', (3,2,'on') on duplicate key update status='off', (15,20,'on') on duplicate key update status='off';
there solution can query?
thanks everyone
you can have 1 on duplicate key
per insert
:
insert `table`(f1, f2, status) select 1 ,5, 'on' union select 3, 2, 'on' union select 15, 20, 'on' on duplicate key update status = 'off';
(of course, can values
; prefer select
because more general.)
Comments
Post a Comment