Solved

Simple Query Question

Posted on 2013-05-24
1
181 Views
Last Modified: 2013-07-03
This is driving me crazy.  I am trying to select all records except for ones that match a certain criteria. Here's some set up:

Here's a sample of a table I'm working with:
Acct              Uniq
02002150B   225
02002150C   225
02002143A   222

Let's say I want to select everything where Acct does not equal 02002150B and Uniq does not equal 225.  I write a query like this:

SELECT * from something where  (Acct != '02002150B' AND Uniq != '225' )

If I run this query, the results returned are as follows:
Acct              Uniq
02002143A   222

Both accounts with the Uniq value of 225 are missing even though I requested a specific Acct number.

What's driving me crazy is that if I were to switch from != to =, the query returns only one result, which is exactly what I would expect it to do.

How can I write a query to return only these results?:
Acct               Uniq
02002150C   225
02002143A   222

Thanks for reading.  I appreciate your time.
0
Comment
Question by:thedeal56
1 Comment
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 500 total points
ID: 39196056
You can use:
WHERE Not (Acct = '02002150B' AND Uniq = '225' )

Open in new window

which is the same as
WHERE (Acct != '02002150B' OR Uniq != '225' )

Open in new window

0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

A lot of articles have been written on splitting mysqldump and grabbing the required tables. A long while back, when Shlomi (http://code.openark.org/blog/mysql/on-restoring-a-single-table-from-mysqldump) had suggested a “sed” way, I actually shell …
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now