Solved

Question about creating a SQL Statement

Posted on 1998-08-26
4
140 Views
Last Modified: 2010-04-30
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")
0
Comment
Question by:PCav
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
lawnranger earned 50 total points
ID: 1431119
SELECT * FROM Appointments, Owners, Pets WHERE
Appointments.OwnerID=Owners.OwnerID AND
Appointments.PetID=Pets.PetID


0
 
LVL 1

Expert Comment

by:raygibbins
ID: 1431120
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
 
LVL 1

Expert Comment

by:lawnranger
ID: 1431121
raygibbins is right...if you need updateable and you are selecting from multiple tables you need JOIN.
0
 

Author Comment

by:PCav
ID: 1431122
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now