mysql - sql query update table with missing fields from another table -
mysql - sql query update table with missing fields from another table -
i have issue sql query/sp i'm trying update table has missing info in specific fields table info in same fields exists , valid. trick here anchor on value in first table. can create work insert into
/ select from
combo, creates duplicate record.
im using mysql 5.x. here details. table missing info thisweek
, table valid info lastweek
. field 1 macaddress
(which exists , anchor) , exists in both tables (for ex. be:ef:ba:be:ca:fe), fields 2-10 in thisweek
blank (''), there info in same fields(fields2-10) in table lastweek
.
update thisweek set thisweek.field2 = lastweek.field2 thisweek.macaddress = lastweek.macaddress , thisweek.filed2 = '';
i know query isn't anywhere close, looking help. again, same macaddress
exists in both tables, difference between tables beingness field2 in thisweek
blank (and shouldn't be) , needs equal lastweek.field2
macaddress
.
thanks all.
i think want following:
update tw set tw.field2 = lw.field2 thisweek tw bring together lastweek lw on tw.macaddress = lw.macaddress tw.field2 = ''
mysql sql join
Comments
Post a Comment