Solved

Question about creating a SQL Statement

Posted on 1998-08-26
4
163 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

696 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