Akhil
Akhil

Reputation: 121

SQL Server join - Working clarification

Can anyone explain why one of the joins is done simply comma-separated? Is there any advantage using it like this? What's the meaning of that join, how to rewrite the query by splitting that join as normal joins?

select distinct 
    aspl.AssessmentId, TestingProviderId, aspl.AssessmentSubjectId, 
    ep.providername, asplg.PerformanceLevelId as PerformanceLevelId, 
    asplg.PerformanceLevelName, asplg.PerformanceLevelColorARGB, 
    null as PerformanceLevelIdCount, null as GroupTotalCount, 
    null as PercentOfGroup, aspl.LastLoadTime 
from 
    AssessmentStudentPerformanceLevel aspl
inner join 
    AssessmentStudentImported asi on aspl.AssessmentStudentCode = asi.AssessmentStudentCode
inner join 
    EducationProvider ep on asi.testingepid=ep.providerid 
left join 
    Student stu on asi.MappedStudentId = stu.StudentId, 
    AssessmentPerformanceLevelGeneric asplg
where 
    aspl.AssessmentId = asplg.AssessmentId 
    and aspl.testingproviderid = ep.providerid 
    and ((IsNull(null, 0) = 0) or (ep.providerid = null))
    and ((IsNull(0, 0) = 0) or (ep.providerlevelid = 0))
    and aspl.AssessmentId = 239012015 
    and aspl.assessmentsubjectid = 1 
order by 
    aspl.AssessmentId, aspl.AssessmentSubjectId, 
    ep.providername, asplg.PerformanceLevelId

In the above query, I mentioned this section

 left join 
     Student stu on asi.MappedStudentId = stu.StudentId, 
     AssessmentPerformanceLevelGeneric asplg

Upvotes: 0

Views: 34

Answers (1)

Nguyễn Hải Triều
Nguyễn Hải Triều

Reputation: 1464

AssessmentPerformanceLevelGeneric is a table with asplg is alias name.

Comma ',' with condition is inner join, without condition is cross join.

SELECT *
FROM A
INNER JOIN B
ON <condition>
=
SELECT *
FROM A, B
WHERE <condition>


SELECT *
FROM A
CROSS JOIN B
=
SELECT *
FROM A, B

Upvotes: 1

Related Questions