ToonMariner Posted October 16, 2007 Share Posted October 16, 2007 Hi guys n gals - a tuff query I am struggling with... I have a table of media (video and audio) these play in a flash player. The videos are fine but the audio have images associated with them... What i need is to select media from this database and when the record is an audio file select an image to go with it. the record has a field `imgs` which contains a , delimted string of numbers - these represent the id of an image in another table. I just want to select a random image from that string of ids or just the 1st id in the string and i'd LOVE to do it in one query! [pre] media table med_id ... type imgs 1 audio 1,2,4,5 2 video 3 video 4 audio 7,8,9 images table img_id path 1 /pics/abc.gif 2 /pics/def.jpg 3 /pics/ghi.gif ....... [/pre] Hope I have explained enough for you to understand - if not tell me off and I'll try again... Quote Link to comment Share on other sites More sharing options...
fenway Posted October 16, 2007 Share Posted October 16, 2007 Delimited number of strings? that's your problem -- you need to normalize this table. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted October 16, 2007 Author Share Posted October 16, 2007 better toi have a field in the images table that links to the media id and not having the imgs fiels rather than my current set up? Quote Link to comment Share on other sites More sharing options...
lemke411 Posted October 16, 2007 Share Posted October 16, 2007 I guess it depends on how you have every thing set up. If you have a set amount of images (img1 - img7) and the audio records relate and reuse the images. Like audio1 uses img1, img3, and img4 and audio2 uses img2, img5, and img1 then I would create another table that holds that relation between the two tables. Quote Link to comment Share on other sites More sharing options...
fenway Posted October 16, 2007 Share Posted October 16, 2007 I guess it depends on how you have every thing set up. If you have a set amount of images (img1 - img7) and the audio records relate and reuse the images. Like audio1 uses img1, img3, and img4 and audio2 uses img2, img5, and img1 then I would create another table that holds that relation between the two tables. Doesn't matter how it's set up -- always use a many-to-many table for stuff like this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.