English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have a particular SQL query now I would like to return the oposite of that query is there a sql statement to do that?

2006-10-15 14:17:01 · 2 answers · asked by tru_story 4 in Computers & Internet Programming & Design

2 answers

Yup, negate it in the WHERE clause.

Or use a subquery that has all of the records that you don't want, then you can select the records that don't match the subquery.

Example 1:

SELECT whatever FROM MyTable WHERE MyColumn is not null (gets all the records wit the not nulled column instead of the records with the nulled column)

Example 2:

SELECT whatever FROM MyTable WHERE MyPrimaryKey NOT IN
(SELECT MyPrimaryKey FROM MyTable WHERE ....)

2006-10-15 14:25:40 · answer #1 · answered by veraperezp 4 · 1 0

Well you could do something like

SELECT * FROM tblStuff WHERE
tblStuff.ID NOT IN (SELECT ID FROM vw_SomeViewWithAQuery)

2006-10-15 15:54:56 · answer #2 · answered by evolver 6 · 0 0

fedest.com, questions and answers