I'm just writing a stock control thing as a test, where basically you have an orders table - if items in the orders table are in there a long time you just put them back on the shelf, so to speak.
Ideally I wanted this kind of pseudo query:
UPDATE stocktable SET stocklev=stocklev+orders.stock WHERE stocktable.itemid=ordertable.itemid AND ordertable.date=TOOOLD;
Without having to code up any extra php my solution was this:
create temporary table tempy AS SELECT stocktab.stockid,stocktab.stocklev+orderlimbo.stocklev
FROM stocktab, orderlimbo
WHERE stocktab.stockid=orderlimbo.stockid;
REPLACE stocktab SELECT * FROM tempy;
And that's it. Admittedly my tables were trivial
UPDATE table1, table2 SET table1.value = table2.value WHERE table1.id = table2.id
Actually for yours it should be as simple as:
REPLACE table1 SELECT * from table2;
If the table schemas are the same, otherwise you can put in the files
REPLACE table1 (field1, field2) SELECT val1,val2 from table2;
Hope I haven't completely cocked that up now, give me a poke if I have.