sql - How can I update multiple MySQL tables based on LIMIT on one table only? -
imagine following 3 tables:
table-a: | id | a-data | sort-data |
table-b: | a-id | b-data |
table-c: | a-id | c-data |
table has less rows other 2 tables. have break table-a in 5 chunks using sorting & limits (20% each). know can update table-a's data based on limit easily. however, can't sort , limit other tables because don't have sort data - have ids table a.
is there fast way can this? have collect ids , use in operator? have join tables using ids , update? what's best query use fast?
update tablea join tableb b on a.id = b.aid join tablec c on a.id = c.aid join (select id tablea order sortdata limit 5) asorted on a.id = asorted.id set a.adata = x, b.bdata = y, c.cdata = z
Comments
Post a Comment