Skip to main content
3 of 7
added 3 characters in body; edited tags
Vidarious
  • 836
  • 3
  • 13
  • 25

mySQL SELECT using a foreign key in another table

I'm having a hard time finding this answer so I'm hoping you guy can help me out.

I have two tables:

event_list with coloumns 'id', 'name', 'date' and event_default with one coloumn 'default_id' which is a foreign key event_list('id')

The idea is that only one event can be default at a time, hence why event_default can only have one value (the id of the event in event_list).

I need a SELECT statement that obtains the event_list data of the event that is currently default. But I want to do this in one SELECT statement which I think I can do rather then two. I am using the PDO framework if that helps.

Vidarious
  • 836
  • 3
  • 13
  • 25