Mysql Copy a field’s value to another related table

The task is to copy the value of the oldfield field to newfield field

UPDATE table2 SET newfield = (SELECT oldfield FROM main_table WHERE table2.qid = main.qid)

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInPrint this pageEmail this to someone

Leave a Reply