[Wolves] Bulk updates to MySQL databases

Andy Jewell Andy.Jewell at sysmicro.co.uk
Mon Sep 14 15:09:00 UTC 2009


From: wolves-bounces at mailman.lug.org.uk [wolves-bounces at mailman.lug.org.uk] On Behalf Of DragonMaster [LUG at clews.homelinux.net]
Sent: 14 September 2009 14:06
To: wolves at mailman.lug.org.uk
Subject: [Wolves] Bulk updates to MySQL databases

Does anyone know if it is possible to perform bulk updates on an insert
similar to the following:

INSERT IGNORE INTO <table> (<field1>, <field2>) VALUES (<Value1>,
<Value2>), (<Value1>, <Value2>) ON DUPLICATE KEY UPDATE <Field1> =
(<Value1>, <Value2>), <Field2> = (<Value1>, <Value2>);

I have got the query to work right up to the multiple updates on the
duplicate key condition, but cannot pursuade the database to update
multiple entries...

Regards,

DM



_______________________________________________
Wolves LUG mailing list
Homepage: http://www.wolveslug.org.uk/
Mailing list: Wolves at mailman.lug.org.uk
Mailing list home: https://mailman.lug.org.uk/mailman/listinfo/wolves

Looks to me like you need to do:


INSERT IGNORE INTO <table> (<field1>, <field2>) VALUES (<Value1>,
<Value2>), (<Value1>, <Value2>) ON DUPLICATE KEY UPDATE <Field1> = VALUES(<Field1>), <Field2> = VALUES(<Field2>);

See: http://dev.mysql.com/doc/refman/5.1/en/insert-on-duplicate.html


Andy D'Arcy Jewell
SysMicro Linux Support

T:  +44 (0) 844 991 8804
M: +44 (0) 7961 605631
F:  +44 (0) 844 357 7020
E:  andy.jewell at sysmicro.co.uk
W: www.sysmicro.co.uk
________________________________________



More information about the Wolves mailing list