tags:

views:

49

answers:

5

How can in a query,

SELECT * WHERE type = 

is everything except "news"? Or should i check that later in the while()?

+2  A: 
SELECT * FROM myTable WHERE type != 'news'
Evan Mulawski
+5  A: 
SELECT * FROM table_name WHERE type != 'news';

Is one way, if you have multiple:

SELECT * FROM table_name WHERE type NOT IN('news', 'other');
Brad F Jacobs
+1  A: 

`SELECT * FROM atable WHERE type != 'news'

Leave as much querying as you can to the database, that's what they are for!

Ed.C
A: 

It's actually

SELECT * FROM my_table WHERE type NOT LIKE 'news'

Claudiu
+1  A: 

The ANSI answer would be SELECT * FROM table_name WHERE type <> 'news'

!= is not the good inequality operator in SQL. 'NOT LIKE' without using wildcards is the exact same thing as the <> operator. NOT IN is also the best solutions if you have to check the equality (or inequality) for many strings.

P.S. I would rather post this as a comment, but I'm afraid I don't totally understand StackOverflow yet, I can't do this yet (or I don't have enough reputation to comment).

Vincent Savard