Use EXISTS instead of IN

I decided to add this forum to keep track of solutions for DB related problems.
I have worked with some brilliant people in my life and the solutions to issues that are usually beyond something you can get at Jack in Box Jackson. They deserve historical marker. This is the historical marked on my map.
Pouzivej data base
Post Reply
hudatolah
Site Admin
Posts: 152
Joined: Thu Apr 04, 2013 8:10 pm
Are You a Headhunter?: Affirmative
Surfer?: Yes

Use EXISTS instead of IN

Post by hudatolah » Tue Dec 28, 2021 1:02 pm

For example:

Code: Select all

select top 10 c.SerialNumber, c.TagNumber from BMC_CORE_BMC_ComputerSystem c
where EXISTS (select top 10  a.serialnumber, a.TagNumber from BMC_CORE_BMC_ComputerSystem a where a.SerialNumber = c.SerialNumber and a.TagNumber IS NOT NULL)
and c.DatasetId = 'BMC.ASSET'
The Blackholesurfer. My surfboard has teeth.