MySQL Forums
Forum List  »  Newbie

Need help withquery
Posted by: Cecil Carpenter
Date: October 18, 2016 05:22PM

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.

Options: ReplyQuote


Subject
Written By
Posted
Need help withquery
October 18, 2016 05:22PM
October 18, 2016 09:30PM
October 19, 2016 10:18AM
October 19, 2016 10:27AM
October 19, 2016 11:04AM
October 19, 2016 03:16PM
October 20, 2016 11:11AM
October 20, 2016 02:01PM


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.