Thursday 16 October 2014

How to update table records with another table

I have a problem with updating records in my table. I am doing research all day but it is just beyond me.
Basics: I have two tables
TABLE1 enter image description here
TABLE2 enter image description here
I need to update nr_g from TABLE1 with id from TABLE2 but only where 'kraj' 'region' 'nazwa_hotelu' from TABLE1 is equal 'country' 'region' 'hotelName' from TABLE2
Solution:
UPDATE merlinx u, merlinx_new s SET u.nr_g = s.id WHERE u.kraj = s.country AND u.nazwa_hotelu = s.hotelName AND u.region = s.region


0 comments:

Post a Comment