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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

The And Operator

Status
Not open for further replies.

Lftsk

Programmer
Jul 11, 2002
25
US
I feel quite silly about this, but it just doesn't seem to work.

I have a table that contains 2 columns.
Duplicates exist for both. But I'll just use Column_1 for the example. Please see the example below.

Column_1 Column_2

CB 12345
CB 67890
BA 12345
BA 67890

In my select statement, all I want to do is disclude the row that has Column_1 = 'CB' AND(!) Column_2 = '12345'

My Select statement is

SELECT *
FROM table1
WHERE (Column_1 <> 'CB' AND Column_2 <> '12345')

But it is also discluding ALL 'CB's. It seems to be evaluating the AND as an OR.

Any help would be greatly appreciated.

 
If I understand your question correctly, either of the following will produce the answer you seek.

Select * From table1
Where col1<>'cb' or col2<>12345

Select * From table1
Where Not (col1='cb' And col2=12345)
Terry L. Broadbent - DBA
Computing Links:
faq183-874 contains &quot;Suggestions for Getting Quick and Appropriate Answers&quot; to your questions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top