>>I have a situation that I have been trying to resolve but was unable to up until now. I have a one to many relationships in a SQL where I need to use a condition on the INNER JOIN table. So, for example, the INNER JOIN table might have three records related to one record from the master table in the SQL. But, I need to assure to take only master records where all the INNER JOIN records for that table would satisfy a condition. What could be an example of such a query?
>
>Could you post some example data and desired result?
>
>I understand your question this way:
>
>SELECT *
> FROM MasterTable
>INNER JOIN ChildTable ON MasterTable.PK = ChildTable.FK AND
> ChildTable.SomeField1 = ???? AND
> ChildTable.SomeField2 = ????
>
>
>BTW this will give you the same results as:
>
>SELECT *
> FROM MasterTable
>INNER JOIN ChildTable ON MasterTable.PK = ChildTable.FK
>WHERE ChildTable.SomeField1 = ???? AND
> ChildTable.SomeField2 = ????
>
>Only if you have LEFT/RIGHT join then it is important where you put the condition.
Hi Boris,
You reply looks like my twin :)
If it's not broken, fix it until it is.
My Blog