query help in joining tables I'm quite green in mysql, but I have been assigned a task for which I completely lost. I have a unique codes table in mysql and then I have another 6 tables for individual clients. I would like to extract those codes which have a value in cat_code = 'wine' from all 5 clients and item_grp_code ='00101' from 1 client since the last client has no cat_code?

Any idea how to do around this?

This is what I tried so far:

SELECT DISTINCT 
  items.code, nxr.departmentcode, nxr.itemgroupcode, las.departmentcode,
  las.itemgrpdesc, las.desc1, nxr.desc1 
FROM (
retail_append.items items 
left outer JOIN 
retail_append.nxr nxr 
  ON (items.code = nxr.code)) 
left outer JOIN 
retail_append.las las 
  ON (items.code = las.code) 
WHERE (las.itemgroupcode = '00101') OR (nxr.categorycode = 'wine');
What about adding the where clause to the join itself?  Something like

left outer JOIN 
retail_append.nxr nxr 
ON (items.code = nxr.code AND nxr.categoryCode = 'wine')) and similar for the other with the item group code?