tags:

views:

894

answers:

3

I'm trying to do this

SELECT `Name`,`Value` FROM `Constants` 
WHERE `Name` NOT IN ('Do not get this one'|'or this one');

But it doesn't seem to work.

How do I get all the values, except for a select few, without doing this:

SELECT `Name`,`Value` FROM `Constants` 
WHERE `Name` != 'Do not get this one' 
AND `Name` != 'or this one'

The first one works with int values, but doesn't work with varchar, is there a syntax like the first one, that performs like the second query?

+3  A: 

It's IN('foo', 'bar'), with a comma, not a pipe.

jkramer
+5  A: 

You should put the constants in a table and then do a select statement from that table. If you absolutely don't want a permanent table you can use a temp table. And if don't want to do that, you can use the IN syntax:

NOT IN ('one', 'two')

Orion Adrian
+1  A: 

The IN syntax uses comma-seperated lists

SELECT `Name`,`Value` FROM `Constants` WHERE `Name` NOT IN ('Do not get this one','or this one');
skaffman