Solved it with Union :)

SELECT images.id,images.name, playlist.title FROM images,playlist WHERE playlist.image_id = images.id
UNION
SELECT images.id,images.name, media.title FROM images,media WHERE media.image_id = images.id
ORDER BY id ASC


On Jun 23, 2006, at 6:44 PM, Graham Anderson wrote:

I am trying to build a query to
1) Get all the results from one table, 'images'
2) For each entry in the 'images' table, find the correct title from the 'playlist' OR 'media' table where images.id = which_table.images_id

images table
id, filename

playlist table
title images_id

media table
title, images_id



So the result would something like
id      filename                title
1       file1                   playlist-title1         // id matches  entry in 
the Playlist table
2       file2                   playlist-title2 
3       file3                   media-title1    //id matches  entry in the 
Media table
4       file4                   media-title2

any help is appreciated as my queries have been pretty simple up to this point



many thanks

g

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to