Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Sum on Union
Message
De
05/02/2013 12:16:15
 
 
À
05/02/2013 12:11:43
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:
01565185
Vues:
32
>
>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?
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform