Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sum on Union
Message
De
05/02/2013 12:20:06
 
 
À
05/02/2013 12:16:15
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01565061
Message ID:
01565186
Vues:
29
>>
>>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform