Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
One to many relationship INNER JOIN condition
Message
 
 
À
14/02/2011 11:34:16
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01500073
Message ID:
01500114
Vues:
33
>>What exactly is the requirement here? Can you post some input and a bit of output?
>>
>>Do you want to only get Master.Numero if all Child records for that Numero (through ManyToManyTable) are Enabled?
>
>My example was using an inner SQL. The reason is because I need to return several fields from the master table. So, this is why for now the inner SQL, as shown in the example, would have been the same if it would have been as is. But, I show the example with the inner SQL so to allow me to expand the example, if needed, and show more master fields I need to return.
>
>But, for the main point of the thread, this is not a factor.
>
>The goal is to make sure that if I have three records in the many to many table and one of them does not satisfy the condition, then the master record should not be returned.

The query I've posted is correct. I also suggest you to read the blog I referenced earlier. You group based on Master field and you use HAVING condition to restrict records to only those where all child records are Enabled.
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform