Wednesday, May 22, 2013

How to update mysql table ignoring the duplicate fields that are already present

here's how you do it.


INSERT INTO thetable (pageid, name, somefield)
VALUES (1, "foo", "first")
ON DUPLICATE KEY UPDATE (somefield = 'first')
taken from

Update one Mysql table with results from another table on a different database

here's how you update one table with results from another database query.


UPDATE
target_database.target_table A                                //database to be updated-target
INNER JOIN source_database.source_table B     //join source database to target
ON B.ProductID = A.ProductID                          //join fields
SET A.Markup = B.Markup                                         //fields to be updated