For more information, see mysqupdate data optimization. Table a has two fields: ready_count and download_count. Table B is a statistical table. the storage engines of tables with type and id are MYISAM. you need to count (1) groupby (type) the data of Table B) then update to the two fields in Table. My current SQL statement is like this: updatea_t1set_t1.ready_count (SELECTcount (1) FROMb_t2WHERE_t2.tid... mysqlselect optimize data update select
Ask the experts to optimize mysq update data
This is the problem.
Table a has two fields: ready_count and download_count.
Table B is a statistical table with type and id.
The storage engines of both tables are MYISAM.
You need to update the data count (1) group by (type) in Table B to the two fields in Table.
My current SQL statement is as follows:
Update a _ t1
Set
_ T1.ready _ count = (
SELECT count (1) FROM B _ t2 WHERE _ t2.tid = _ t1.id and _ t2.type = 1
),
_ T1.download _ count = (
SELECT count (1) FROM B _ t2 WHERE _ t2.tid = _ t1.id and _ t2.type = 2
),