An update to my earlier post. I'm getting a bit closer but still not there. In the following query:
select decheader.code, decheader.height, decheader.width, decplacement.position, decplacement.product from decheader left join decplacement on decheader.code = decplacement.code and (decheader.code = '000042' and (decplacement.product = 'PLS159' or decplacement.product is null)) or (decheader.code = '000043' and (decplacement.product = 'SWS002' or decplacement.product is null)) or (decheader.code = '000137' and (decplacement.product = 'PLS150' or decplacement.product is null)) or (decheader.code = '000042' and (decplacement.product = 'PLS150' or decplacement.product is null)) where decheader.code = '000042' or decheader.code = '000043' or decheader.code = '000137' or decheader.code = '000042' In the above example, 3 records are returned with correct values. Code 000042 does not have an associated product of PLS150 and does not return a record with Null values for the decplacement table as I want it to do. Basically, the code I query on will always exist in the decheader table. It may or may not exist in the decplacement table and subsequently it may or may not have a corresponding product. I need a record back for each code/product combination even if the record only has the details from the decheader table. I should also add that decheader.code = '000042' is in twice in the where clause because I build the sql string dynamically?? I understand why my query does not work, but I need to know more about joins to resolve my issue. **************************************************** This e-mail is intended for the recipient only and may contain confidential information. If you are not the intended recipient then you should reply to the sender and take no further ation based upon the content of the message. Internet e-mails are not necessarily secure and CCM Limited does not accept any responsibility for changes made to this message. Although checks have been made to ensure this message and any attchments are free from viruses the recipient should ensure that this is the case. **************************************************** --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php