Page 1 of 1

opposite of WHERE IN

Posted: Sun Dec 30, 2007 12:04 am
by GeXus
Is there an opposite to where in function? Basically I have a text column with country codes such as 'GB, US, AU' and I want to select only the rows that have 'GB'

Posted: Sun Dec 30, 2007 12:15 am
by John Cartwright
I want to select only the rows that have 'GB'
I must be misunderstanding you since the solution is far too obvious

Code: Select all

WHERE country = 'GB'

Posted: Sun Dec 30, 2007 12:22 am
by GeXus
Ha, no the column holds comma delimited values. So you get one value 'GB' from the user, then have to find matching rows from a column that has the comma delimited values..

However I did just find a solution that works..

Code: Select all

SELECT id
FROM `geo_settings`
WHERE find_in_set( 'GB', `country_codes` ) != ''

Posted: Mon Dec 31, 2007 2:27 pm
by jamiel

Code: Select all

LIKE '%GB%'