I have three mysql tables related on the field imageid
- images
- image_cat........one to many from images
- image_group....one to many from images
Below is the query i'm working with and it is not giving me the respnse i'm looking for. I think I have the join messed up. The WHERE clause should tell you what i'm expecting. It seems the join to the image_group table is not working correctly. Any ideas?
Select DISTINCT
i.imageid,
i.image_name,
i.inks,
ig.groupid,
ic.catid
FROM
images as i INNER JOIN image_cat as ic USING (imageid),
images as ii INNER JOIN image_group as ig USING (imageid)
WHERE
i.image_name like 'tree%'
OR
i.keyword like 'tree%'
OR
ic.catid='1'
AND
ig.groupid='2'
AND
i.status='active';