i trying update field based on table's field using join:
update transactions join products on products.link = transactions.product_id set transactions.user_id = products.user_id transactions.user_id != products.user_id
however, taking long time (over 15 minutes). products has 10k rows, transactions has 90k rows. there anyway can optimize query?
transactions table:
id int(11) transaction_id varchar(255) user_id int(11) product_id varchar(50)
products table:
id int(11) user_id int(11) link varchar(45)
i not sure if sql can help. can try?
update transactions t1 inner join ( select t2.id , p.user_id transactions t2, projects p t2.product_id = p.link , t2.user_id != p.user_id ) t3 on t1.id = t3.id set t1.user_id = t3.user_id
Comments
Post a Comment