Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Simple Query Question

Posted on 2013-05-24
1
Medium Priority
?
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 35

Accepted Solution

by:
Robert Schutt earned 2000 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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

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

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

704 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