selecting when not in array

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
ckuipers
Forum Commoner
Posts: 61
Joined: Mon Mar 24, 2003 6:10 am

selecting when not in array

Post by ckuipers »

I need a bit of help on this. I'm trying to get mysql to select something when a value is not part of a list:

Code: Select all

SELECT DISTINCT project FROM pos LEFT JOIN region_lookup ON pos.country_id= region_lookup.country_id WHERE project <> '301' AND project <> '302' AND project <> '330' AND status <> 'canceled' AND region_lookup.region_id= '$Region' ORDER BY project
Now that I'm upgrading the database, this list of projects gets longer. Is there a way to have it combined in an array?

Thx
ckuipers
Forum Commoner
Posts: 61
Joined: Mon Mar 24, 2003 6:10 am

Post by ckuipers »

Found it:

Code: Select all

MySQLQuery("SELECT DISTINCT project FROM pos LEFT JOIN region_lookup ON pos.country_id= region_lookup.country_id WHERE project NOT IN (301, 302, 330) AND status <> 'canceled' AND region_lookup.region_id= '$Region' ORDER BY project
Post Reply