?
Solved

I am trying to do a query, help

Posted on 2009-04-21
6
Medium Priority
?
153 Views
Last Modified: 2012-05-06
I am trying to do a query that if a column say column A = 2 and column B =0, omit them from the query.  Hod do I do this?
0
Comment
Question by:VBBRett
  • 4
  • 2
6 Comments
 
LVL 74

Accepted Solution

by:
sdstuber earned 2000 total points
ID: 24197414
select * from your_table
where not (columnA=2 and columnB=0)
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 24197421
or...

select * from your_table
where columnA != 2 or columnB != 0

0
 
LVL 74

Expert Comment

by:sdstuber
ID: 24197431
note, if you have NULLs in either of those columns you might not get the results you are expecting.

if you don't have NULLs then no problem.
if you do, then please specify what action you would like to take when A or B or both are NULL
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 41

Expert Comment

by:ralmada
ID: 24197778

In SQL Server:
 
select * from yourtable where columnA = 2 and ColumnB = 0
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 24197805
ralmada, I think you're missing some "NOT"s  

asker wanted to OMIT the 2 and 0 records.  See posts above.

Unless I'm misunderstanding the request
0
 
LVL 41

Expert Comment

by:ralmada
ID: 24197835
sorry I meant
In SQL Server:

select * from yourtable where columnA <> 2 and ColumnB <> 0
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question