Solved

Help with SQL Query

Posted on 2012-03-12
2
271 Views
Last Modified: 2012-03-12
We want to select all the rows that have an AID = 1 but don't have a matching AID = 2 with the same BID.

select ID, PersonID, AID, BID from [track] order by id

Tractrack table
0
Comment
Question by:tampsystems
[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
2 Comments
 
LVL 25

Accepted Solution

by:
jogos earned 500 total points
ID: 37709479
select t1.ID, t1.PersonID, t1.AID, t1.BID
from [track] as t1
where not exists
(select 1
from track as t2
where t2.BID = t1.BID and T2.AID = 2
)
 order by t1.id
0
 

Author Closing Comment

by:tampsystems
ID: 37709561
thanks, you saved me a ton of time today!
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SQL eating up memory? 16 41
SQL Server Express or Standard? 5 29
Options for Linking SQL tables to Access 2013 9 42
SQL Syntax 6 32
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

733 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