* Andreas Ahlenstorf > Roger Baklund schrieb am Freitag, 17. Oktober 2003 um 01:56: > > > I think you need the LEFT JOIN: > > <URL: http://www.mysql.com/doc/en/JOIN.html > > > I thought about that before, but how to catch up the problem, that I > have different tables where I have to get the ProdID and the > StationID?
You can LEFT JOIN both "join paths", one of them will be NULL, the other contain data. You can use IF() to select the right one, something like this: SELECT IF(ISNULL(d.ProdID),d2.status, d.status) AS status FROM Picklists AS a LEFT JOIN PicklistData AS b ON a.ID = b.Picklist LEFT JOIN ProdID AS c ON b.EAN = c.EAN LEFT JOIN EncodingData AS d ON c.StationID = d.StationID AND c.ProdID = d.ProdID LEFT JOIN Trackdata AS c2 ON b.ISRC = c2.ISRC LEFT JOIN EncodingData AS d2 ON c2.StationID = d2.StationID AND c2.ProdID = d2.ProdID WHERE a.ID = '1' -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]