Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sum on Union
Message
From
05/02/2013 12:20:06
 
 
To
05/02/2013 12:16:15
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01565061
Message ID:
01565186
Views:
28
>>
>>UPDATE Menu
>>  SET Count=ISNULL(A.RecordCount,0)+ISNULL(B.RecordCount,0)
>>FROM
>>(SELECT Menu.Numero,COUNT(*) AS RecordCount
>>	FROM Menu
>>	INNER JOIN MenuEntity ON Menu.Numero=MenuEntity.NoMenu
>> INNER JOIN MenuPrivilege ON Menu.Numero=MenuPrivilege.NoMenu
>> INNER JOIN MenuRole ON Menu.Numero=MenuRole.NoMenu
>> INNER JOIN Member ON MenuEntity.NoEntity=Member.NoEntity AND
>>  MenuPrivilege.NoType=Member.NoType AND MenuRole.NoRole=Member.NoRole
>> WHERE Menu.Numero NOT IN (SELECT Menu.Numero FROM MenuPrivilegeExceptionCase
>> INNER JOIN Menu ON MenuPrivilegeExceptionCase.NoMenu=Menu.Numero
>> WHERE MenuPrivilegeExceptionCase.NoMember=Member.Numero)
>> GROUP BY Menu.Numero) A
>>FULL JOIN
>> (SELECT Menu.Numero,COUNT(*) AS RecordCount
>> FROM Menu
>> INNER JOIN MenuPrivilegeExceptionCase ON Menu.Numero=MenuPrivilegeExceptionCase.NoMenu AND
>>  MenuPrivilegeExceptionCase.Enabled=1
>> INNER JOIN MenuEntity ON Menu.Numero=MenuEntity.NoMenu
>> INNER JOIN Member ON MenuEntity.NoEntity=Member.NoEntity
>> WHERE MenuPrivilegeExceptionCase.NoMember=Member.Numero
>> GROUP BY Menu.Numero) B ON B.Numero = A.Numero
>>WHERE Menu.Numero = ISNULL(A.Numero,B.Numero)
>>
>
>I would then assume that this approach is a little bit better as it simplifies a little bit the SQL command as I do not have to have an additional INNER JOIN as defined in message #1565063. Can you confirm this?

Put the FROM Menu INNER ... or not put it is the same on the execute plan

The true difference is on FULL JOIN instead the UNION.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform