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 TwitterPrint this pageEmail this to someoneShare on Reddit

Leave a Reply