How can in a query,
SE开发者_如何学PythonLECT * WHERE type =
is everything except "news"? Or should i check that later in the while()?
SELECT * FROM table_name WHERE type != 'news';
Is one way, if you have multiple:
SELECT * FROM table_name WHERE type NOT IN('news', 'other');
SELECT * FROM myTable WHERE type != 'news'
`SELECT * FROM atable WHERE type != 'news'
Leave as much querying as you can to the database, that's what they are for!
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).
It's actually
SELECT * FROM my_table WHERE type NOT LIKE 'news'
精彩评论