views:

18

answers:

2

Some one please explain me how does this query works

SELECT 'WRITEBOARDCOMMENT' AS Type,
wbc.CommentText AS Content,
wb.WBId AS Id,
null AS ToDoListName,
null AS DueDate,
u.FirstName + ' ' + u.LastName AS ActivityBy,
wbc.[Date] as Date,
u.FirstName + ' ' + u.LastName as PartyName,
comp.CompanyId AS CompanyId,
comp.CompanyName AS CompanyName,
p.ProjectName,
p.ProjectId,
wbc.WBCmtId AS SubId,
p.ProjectStartPageId AS ProjectStartPageId  
FROM 
WriteboardComment AS wbc,
WriteBoardVersions AS wbv,
WriteBoard AS wb,
Project AS p,[user] AS u,
Company AS comp 
where 
wbc.wbversionid=wbv.wbversionsid and
wbv.WBId=wb.WBId and
wb.ProjectId=p.ProjectId and
p.ProjectId=@projectid and
wbc.CommentedBy=u.UserId and
p.PrimaryCompanyId=comp.CompanyId

What is the advantage of joining the tables like this.I found out this one in one project db code.

A: 

This used to be the old style of doing the joins. There is no advantage over the classical join version.

Yves M.
+1  A: 

There is no advantage, this is an old style join and you can easily shoot yourself in the foot when you mess up/leave out the WHERE clause and then you create a cartesian product/cross join by mistake

SQLMenace