Can anyone please help – See below two tables
Table - Master
Field 1 - Id
Field 2 - Name
Field 3 - Address
Field 4 - Effective End Date
Filed 5 - Last updated date
Table - Child
Field 1 - Id
Field 2 - Name
Field 3 - Address
I need to do lookup from Parent in child and if Parent record doesn’t exist (based on Id, Name and Address) then update the effective end date and last updated date of Table Master.
New to SQL, so struggling with this basic query.
Regards
Try it like this:
If you want to update records in
Masterwhen a record with sameId, Name, Addressdoes not exist inChildtable you can do it like this. There’s also anOUTPUTclause that returns rows affected by the update. The dates are being updated to today’s date but you can set that to anything you need.Here is an SQL Fiddle