Question about creating a SQL Statement

I have the following tables and fields in an Access database
Appointments
    AppointmentID  (key field)
    OwnerID        (link field to other table)
    PetID          (link field to other table)
    AppointmentDate
Owners
    OwnerID     (key field)
    Name
Pets
    PetID       (key field)
    Name

What I need is a SQL Statement that will put them all together, ie so that I can refer to
.fields("Owners.Name")  and
.fields("Pet.Name")
PCavAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
lawnrangerConnect With a Mentor Commented:
SELECT * FROM Appointments, Owners, Pets WHERE
Appointments.OwnerID=Owners.OwnerID AND
Appointments.PetID=Pets.PetID


0
 
raygibbinsCommented:
I would have used the following , it allow you to add records to the recordset if it is a dynaset

SELECT Owners.Owner, Pets.PetName, Appointments.AppontmentDate
FROM Pets INNER JOIN (Owners INNER JOIN Appointments ON Owners.OwnerID = Appointments.OwnerID) ON Pets.PetID = Appointments.PetID;

0
 
lawnrangerCommented:
raygibbins is right...if you need updateable and you are selecting from multiple tables you need JOIN.
0
 
PCavAuthor Commented:
Thanks Ray, but I already gave the points to lawnranger.  I don't need to update the records, just cycle through them and add the information to a listview control
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.