Let's say you have three tables named Item, Event, and Seat, constructed as such:
Item
Id (int)
Event_id (int)
Section (int)
Event
Id (int)
Venue_id (int)
Configuration (int)
Seat
Id (int)
Venue_id (int)
Configuration (int)
Section (int)
Face_value (int)
I'm trying to construct a MySQL query that pulls all entries from the Item table and includes the Face Value for each item. In order to do this, the query must:
- Use the Item.Event_id value and match it to Event.Id
- For that entry in the Event table, it must take the Event.Venue_id and Event.Configuration and find an entry in the Seat table that has the same values for both AND also has the same value for Section as Item.Section. It must then return Face_value.
I'm having a lot of trouble constructing this because of the way it combines info from all three tables. Any idea on how to approach it? Or is this impossible to do in SQL?