1: 2: 3: 4: 5: 6: 7:
SELECT D.* , DocState.DocStateID , IIF(IsNull(DocState.DocStateID),"Exists", "Does Not Exist") FROM (SELECT Doc.DocID , State.StateCode FROM State, Doc ) D LEFT OUTER JOIN DocState DS ON D.DocID = DS.DocID AND D.StateID = DS.StateID