Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

selecting all except one

Status
Not open for further replies.

filipe26

Programmer
Mar 17, 2003
152
PT
Hi .I want to select all records with a certain filter except one.
I have:

select * from inverno(inverno is a table)
where tipo="Pijamas"

and know i want to do something like that:

except where nome="fi" and tipo="ca"

How to do that?Thanks.
 
SELECT * FROM inverno WHERE (nome <> "fi") OR (tipo <> "ca")
 
Heya fellas.

Griffyn you prolly ment:
SELECT * FROM inverno WHERE (nome <> "fi")[red]AND[/red](tipo <> "ca")

--- McMerfy
 
Since you are already limiting yourself to the case
where tipo="Pijamas"
then there is no need to add
and tipo <> "ca"

Unless you mis-typed the column names, all you need is

select * from inverno
where tipo="Pijamas" and nome<>"fi"

 
Let me clear this up:

Zathras, filipe26 pointed out his exclusion was meant to be similar to his tipo="Pijamas", not including it.

And McMerfy, I did mean to use OR. Consider the following records:
Code:
NOME   TIPO
fi     ca
fi     xx
xx     ca
xx     xx

filipe26 said he wants a query to show everything except where nome='fi' AND tipo='ca'. That would mean the bottom three records in my example. Let's have a look at what your query would return. Obviously, the first one is excluded: correct. However, both the second and third ones will be excluded as well: incorrect.
 
Yes what i want to do is select all records excepting one in the same grid.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top