Solved

Simple Query Question

Posted on 2013-05-24
1
182 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Stop the possibility of taking backup in MySQL on Ubuntu 1 74
Generate report pulling data (links) from three tables 31 58
Instering to MySQL table 5 38
Amazon Redshift 2 26
I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
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.
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

911 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

23 Experts available now in Live!

Get 1:1 Help Now