MySQL Database Query - help
Posted: Wed Jun 25, 2003 9:14 am
Hi
I have a table (keyword_images) with fields
IMAGE number(6)
KEYWORD number(6)
and I want to run a query where I return a list of images that have a keyword match for all of (1,2,3,4).
IN is no good
because that give me any image that has one or more of the keywords.
AND is no good
because individual records don't have all 4 keywords attached.
Anyone got any ideas?
--- Phil ---

I have a table (keyword_images) with fields
IMAGE number(6)
KEYWORD number(6)
and I want to run a query where I return a list of images that have a keyword match for all of (1,2,3,4).
IN is no good
Code: Select all
SELECT distinct image
FROM keyword_images
WHERE keyword in (1,2,3,4)AND is no good
Code: Select all
SELECT distinct image
FROM keyword_images
WHERE keyword=1 AND keyword=2 AND keyword=3 AND keyword=4Anyone got any ideas?
--- Phil ---