• ChrisM@Work (8/20/2013)


    This works and the explanation fits too, but why LEFT JOIN to the link table? dpd shouldn't contain any doctors which aren't in the doctors table, or drugs which aren't in the drugs table.

    I was simply building upon the OP's original query. Since it started with a left join, I continued to use it since it still gave the correct output. What each table may or may not contain as correct data is highly dependent upon the constraints of which we are not privy to.

    __________________________________________________________________________________________________________
    How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/