> Already tried that, but is 2 appears at the end of the list 
> is doesn't get picked up because there is no comma at the end 
> of the list
 
Are there spaces between the commas???

If not then

SELECT  gallery_id, gallery_name
FROM            galleries
WHERE           
        keywords = '2'    -- 2 on it's own
OR
        keywords LIKE '%,2,%'  -- 2 in any position but first and last
OR
        keywords LIKE '2,%' -- 2 in first position
OR      
        keywords LIKE '%,2' -- 2 in last position

If there are spaces between the commas and the keywords are single words or
numberic digits then you could collapse all spaces...

SELECT  gallery_id, gallery_name
FROM            galleries
WHERE           
        REPLACE(keywords,' ','') = '2'    -- 2 on it's own
OR
        REPLACE(keywords,' ','') LIKE '%,2,%'  -- 2 in any position but
first and last
OR
        REPLACE(keywords,' ','') LIKE '2,%' -- 2 in first position
OR      
        REPLACE(keywords,' ','') LIKE '%,2' -- 2 in last position
 
Done very quickly so I may have missed something, I'm sure others will point
it out if I have!

Cheers

Dean
 
 


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to