August 10, 2013 at 10:53 pm
hi i have done a subqueries but but it is not displaying any records.
select SubjectCode,SubjectName,Description
from Subject
Where SubjectCode In
(select SubjectCode
from Absence
where SubjectCode IN
(select SubjectCode
from Absence
Where SubjectCode like 'BS%' and LessonDate = '20130305'));
Anyone can help me.
August 11, 2013 at 3:39 am
That's a bit convoluted, you don't need two nested subqueries
select SubjectCode,SubjectName,Description
from Subject
Where SubjectCode In
(select SubjectCode
Where SubjectCode like 'BS%' and LessonDate = '20130305');
That'll do the same thing.
Does that subquery return any nulls? If so, the IN will return no matches
http://sqlinthewild.co.za/index.php/2010/02/18/not-exists-vs-not-in/
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply