Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Help to build a Query
Message
 
 
À
25/10/2008 22:37:44
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01357186
Message ID:
01357189
Vues:
25
>Hello, I have to build a query from 3 tables:
>
>Table Usuarios:
>IDusuario    Nombre
>1                Charles
>2                George
>
>Table ModAsg:
>Codmodulo Idusuario
>1                1
>2                1
>3                1
>1                2
>
>
>Table Modulos:
>Cod    Modulos
>1        Mymodule1
>2        Mymodule2
>3        Mymodule3
>4        Mymodule4
>
>When I use this query:
>Select Usuario.Nombre, Modulos.Modulo from Usuario, ModAsg, Modulos where Usuario.Idusuario=Modasg.idusuario and Modasg.codmodulo=Modulos.cod and Usuario.idusuario = 2
>
>It displays:
>George and Mymodule1
>
>I need now to show for george the modules that he doesn't have yet, like
>George and Mymodule2, Mymodule3, Mymodule4
>
>How can i do it?
Select Cod, Modulos from Modulos M ;
INNER JOIN ModAsg MA on M.Cod = M.Codmodulo ;
where MA.IDusuario not in  (select IDusuario    from   Usuarios where Nombre = 'George')
If you need to list all people with the modules they don't have, the query would be more complex.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform