How Would I Write This Sql Update Query?
Say I have two tables: new_dogs <<---- CONTAINS DOGS SPOTTED TODAY --------- name breed color location found_date dog_locations <<---- CONTAINS A HISTORY OF ALL DOG
Solution 1:
UPDATE dog_locations SET thru_date =<actualdate or whichever date>FROM dog_locations dl
WHERENOTEXISTS (SELECT name, breed, location, found_date
FROM new_dogs nd
WHERE (nd.name = dl.name) AND (nd.breed = dl.breed)
AND (nd.location = dl.location)
AND (nd.found_date = dl.from_date));
Cheers Anja
But you should really rethink your database design and follow LukLeds idea introducing a table dogs...
Post a Comment for "How Would I Write This Sql Update Query?"