opposite of WHERE IN

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

opposite of WHERE IN

Post 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'
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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'
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post 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` ) != ''
jamiel
Forum Contributor
Posts: 276
Joined: Wed Feb 22, 2006 5:17 am
Location: London, United Kingdom

Post by jamiel »

Code: Select all

LIKE '%GB%'
Post Reply