I have 3 tables as mentioned below:
Users
Code Name NW London
1 Bill ---- ----
Contacts
Code Country
1 USA
Location
Country City
USA NW
I need to update Users.NW = 1 in the Users Table. There are other cities like NW, London, Paris etc. In respective cities i need to update 1 and rest should be 0.
So, expected output
1 Bill 1 0
2 Steve 0 1
I hope i am clear to you. Thanks in advanced. This query is not working:
UPDATE Users SET NW='1' WHERE
(SELECT Users.Code, Contacts.code FROM Contacts
LEFT JOIN ON Users.code = Contacts.code AND
INNER JOIN ON Contacts.Country = Location.Country
) AND Users.NW = Location.City;