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

x
?
Solved

Help with SQL Query

Posted on 2012-03-12
2
Medium Priority
?
275 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 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

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