INSERT INTO component_cc (SELECT '<user id>' as user_id, component_id FROM component_cc JOIN components ON component_cc.component_id = components.id WHERE components.product_id = <product id>)
Tag: mysql
MySQL: UPDATE query based on SELECT query
update tableA a left join tableB b on a.name_a = b.name_b set validation_check = if(start_dts > end_dts, 'VALID', '')
UPDATE payments p INNER JOIN users u ON p.pay_id=u.user_id SET p.pay_email=u.user_email, p.pay_firstname=u.user_firstname, p.pay_lastname=u.user_lastname, p.pay_date=u.user_date
[via]http://stackoverflow.com/a/1262848[/via]