David Glover
asked on
How do I add new rows to a new table where there isn't an existing row that matches the foreign key?
I want to create records in a table with a value for every matching record in another table but only if there isn't already a record.
So for the following :
Customers Locations
CustomerID CustomerID Location
1 2 Unknown
2 3 England
3 4 Spain
4
5
I would like for the sql command to end up with the tables looking like this:
Customers Locations
CustomerID CustomerID Location
1 1 Unknown
2 2 Unknown
3 3 England
4 4 Spain
5 5 Unknown
So for the following :
Customers Locations
CustomerID CustomerID Location
1 2 Unknown
2 3 England
3 4 Spain
4
5
I would like for the sql command to end up with the tables looking like this:
Customers Locations
CustomerID CustomerID Location
1 1 Unknown
2 2 Unknown
3 3 England
4 4 Spain
5 5 Unknown
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Guess, we had the same thought, UnifiedIS. :)
ASKER
Thanks guys, I split the points on this occasion because you actually seemed to answer simultaneously!
Thanks again,
Thanks again,