Hi All,
I realized I need another table in my established db to go between two other tables. The new table, tblFamily, has one PK and two FK for the other two tables:
tblAddress--->tblFamily-->tblPeople
tblAddress: PK AddressID
tblFamily: PK FamilyID
tblFamily: FK AddressID
tblFamily: FK PeopleID
tblPeople: PK PeopleID
tblPeople: FKAddressID
I used an append query on tblFamily to fill in the AddressID from tblAddress.
I'm trying to write an UPDATE query using SELECT DISTINCT to copy the PeopleID into tblFamily.PeopleID. I need the first PeopleID from each unique AddressID from tblPeople.
My update query says it can't find database B. Why is it looking outside of the current db? If it were looking in the correct place, would this work?
UPDATE B.PeopleID
SET PeopleID = (SELECT DISTINCT A.PeopleID
FROM tblPeople A
INNER JOIN tblFamily B
ON A.AddressID = B.AddressID)
WHERE B.PeopleID is null
Thanks for your help.
I realized I need another table in my established db to go between two other tables. The new table, tblFamily, has one PK and two FK for the other two tables:
tblAddress--->tblFamily-->tblPeople
tblAddress: PK AddressID
tblFamily: PK FamilyID
tblFamily: FK AddressID
tblFamily: FK PeopleID
tblPeople: PK PeopleID
tblPeople: FKAddressID
I used an append query on tblFamily to fill in the AddressID from tblAddress.
I'm trying to write an UPDATE query using SELECT DISTINCT to copy the PeopleID into tblFamily.PeopleID. I need the first PeopleID from each unique AddressID from tblPeople.
My update query says it can't find database B. Why is it looking outside of the current db? If it were looking in the correct place, would this work?
UPDATE B.PeopleID
SET PeopleID = (SELECT DISTINCT A.PeopleID
FROM tblPeople A
INNER JOIN tblFamily B
ON A.AddressID = B.AddressID)
WHERE B.PeopleID is null
Thanks for your help.
Last edited: