Hi all
I'm having the most frustrating time trying to select data from two different tables that relate to each other.
I have a database that has the following tables: images, gallery, categories, news (news is somewhat irrelevant to my current problem)
The gallery table has the following columns:
_____________________
| id | title | category | date |
******************************
| 1 | Party 1 | party | 0000-00-00 |
| 2 | Dinner Event 1 | dinner | 0000-00-00 |
The images table has the following columns:
_______________________________________
| id | image | thumb | category | relation_id | date |
*******************************************************
| 1 | path/party_image_1.jpg | path/party_thumb_1.jpg | party | 1 | 0000-00-00 |
| 2 | path/party_image_2.jpg | path/party_thumb_2.jpg | party | 1 | 0000-00-00 |
| 3 | path/party_image_3.jpg | path/party_thumb_3.jpg | party | 1 | 0000-00-00 |
| 4 | path/dinner_image_1.jpg | path/dinner_thumb_1.jpg | dinner | 2 | 0000-00-00 |
| 5 | path/dinner_image_2.jpg | path/dinner_thumb_2.jpg | dinner | 2 | 0000-00-00 |
| 6 | path/dinner_image_3.jpg | path/dinner_thumb_3.jpg | dinner | 2 | 0000-00-00 |
| 7 | path/dinner_image_4.jpg | path/dinner_thumb_4.jpg | dinner | 2 | 0000-00-00 |
| 8 | path/dinner_image_5.jpg | path/dinner_thumb_5.jpg | dinner | 2 | 0000-00-00 |
Now let's pretend that there are 5 entries in the gallery table that have the category 'dinner' and that there are several images that relate to each of these gallery table entries (relation_id in the images table is the id of the entry inside the gallery table).
I want to select each entry from the gallery table that belongs to the 'dinner' category, as well as the first image that relates to the entry and display it on my page.
Any help would be highly appreciated!!!