Possible duplicate:
mysql - an array in several columns
I have two tables:
Message table
PostID | Gallery
1 | 4,7,8,12,13
2 | 1,2,3,4
3 | 5,8,9
4 | 3,6,11,14
The values in the Gallery are the primary keys in the Images table:
Image table
ImageID | FileName
1 | something.jpg
2 | lorem.jpg
3 | ipsum.jpg
4 | what.jpg
5 | why.jpg
The reason I am doing this rather than just adding the PostID key to the Images table is because these images can be associated with many different messages. I suppose I could add another table for the relationship, but a comma-separated value is easier to work using the jQuery script, which I use to add to it.
If I’m on a page that requires images related to PostID 3, what query can I run to display all the file names for it?