Need help withquery
I have the following query that is returning multiple guests for a specific event if a person has more than one guest for different events no matter what event number I use:
SELECT DISTINCT p.Preferred_Name, p.Last_Name, g.Guest_First_Name, g.Guest_Last_Name, e.Event_Description FROM person p, guest g, attendee a, `event` e
WHERE p.Person_ID = g.Person_ID
AND g.Person_ID = a.Person_ID
AND a.Guest_Attended = 'Y'
AND a.Event_ID = e.Event_ID
AND a.Event_ID = 4
ORDER BY p.Last_Name, p.First_Name, g.Guest_Last_Name, g.Guest_First_Name
The database has foreign keys in the person table for the guest table and the attendee table. The attendee table has a foreign key for the event table.
I think I understand the issue, but I cannot create a query that works correctly. I have tried this with Joins, but I still cannot get it to work correctly.
Subject
Written By
Posted
Need help withquery
October 18, 2016 05:22PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.