Hi again and thanks!
johanafm;10930206 wrote:FROM event, event_artist, artist etc...
WHERE event.id = event_artist.event_id AND etc
I understand how to make that query but it is obviously hard to me to explain what I need...
So I will try differently =)
My table events:
[CODE] ID | eventTitle | etc.
1 | event 1 |
2 | event 2 |
etc.[/CODE]
Table artists:
[CODE] ID | artistName | etc.
1 | artist 1 |
2 | artist 2 |
etc.[/CODE]
Table descriptions:
[CODE] ID | artistDesc | etc.
1 | artist 1 description 1 |
2 | artist 1 description 2 |
3 | artist 2 description 1 |
4 | artist 2 description 2 |
5 | artist 3 description 1 |
etc.[/CODE]
I made also junction tables events_artists and artists_desctriptions. Both of them have only 2 foreign keys and serve only for linking event, artist and description IDs.
Notice in my descriptions table - artist can have many descriptions. That actually means that each description belongs to one specific event.
If I do a query like this:
$q = "SELECT
events.*,artists.*,descriptions.*,events_artists.*,artists_descriptions.*
FROM
events,artists,descriptions,events_artists,artists_descriptions
WHERE
events.eventID = events_artists.eventID AND
events_artists.artistID = artists.artistID AND
artists.artistID = artists_descriptions.artistID AND
artists_descriptions.descID = descriptions.descID";
I will get all the descriptions for a particular artist. But none of descriptions will be aware which event they belong toβ¦
What I want to display to user is something like this:
EVENT 1
artist 1
artist 1 description 1
artist 2
artist 2 description 2
EVENT 2
artist 3
artist 3 description 6
artist 1
artist 1 description 3
Should I make a junction table for event-description relation? If I do, I don't know exactly how to use it, uff! =)
Or maybe my problem isn't solvable with a simple query? Should I do something with php too? Sorry but I am totally confused =)
I hope you understood my problem now⦠Thanks in advance!