I have two tables, one stores events for a user and the other stores the photos for each event. The layout is as follows:
event (event_id,
event_title,
event_description,
event_date,
event_time,
event_city,
event_state,
event_user)
photo (photo_id,
photo_photo,
photo_thumbnail,
photo_caption,
photo_event)
On my event page I want to display all of my events in a grid. Now, the catch is that I am using a live album preview with jQuery (http://tutorialzine.com/2012/12/album-photo-previews-jquery/) so I need all of the thumbnails for each event to be returned as well. Can I do this with a single query?
My current query is
"SELECT event.*, photo_thumbnail FROM event
LEFT JOIN photo ON event_id = photo_event
WHERE event_user = ?;"
but it is giving me the event information for each photo returned which is unnecessary. I just need the event information once along with every photo for each event. Any help is appreciated.
I would use something like:
This will give a thumbnails column in your results which will be a comma separated list of the thumbnails.