I have two tables calendar and customer table. Calendar table have a
“customer” column which has customer table “ID” as value. But unfortunately,
this calendar customer field value was wrongly populated with other values.
Both tables have these common fields Date, SeatingID and BusID. How to update
the calendar table customer field based on these common fields?.
Below is the structure of both tables.
Customer Table ion here" src="https://imgs.xnip.cn/cj/l/11/c9a25393-96da-4c4f-b2c3-ded891bcdee7.jpg" />
calendar Table
update calendar ca left join customer c
on c.DateofTravel=ca.Date and c.SeatingID=ca.SeatingID and c.BusID=ca.BusID
set
ca.Customer=c.ID;