I have a query that pulls data from 3 tables combining those tables and limiting the information to data that is less than 60 days old and doesn’t contain specific information in one of the fields. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-comfficeffice" /><o></o>
<o></o>
I also need this same query or another query to further limit this data based on another table. <o></o>
<o></o>
If the field contains data that is on Narr_table code_1 field I don’t want to include it.<o></o>
<o></o>
The sql is working for everything except the Narr_table part. These fields could change on a regular basis so I don’t want to write them in as criteria. I would rather have the criteria check the table for matching information. Currently there are code_1 fields.<o></o>
<o></o>
The current working SQL looks like the below:<o></o>
<o></o>
<o></o>
<o></o>
I also need this same query or another query to further limit this data based on another table. <o></o>
<o></o>
If the field contains data that is on Narr_table code_1 field I don’t want to include it.<o></o>
<o></o>
The sql is working for everything except the Narr_table part. These fields could change on a regular basis so I don’t want to write them in as criteria. I would rather have the criteria check the table for matching information. Currently there are code_1 fields.<o></o>
<o></o>
The current working SQL looks like the below:<o></o>
<o></o>
Rich (BB code):
<o:p></o:p>
SELECT Primary_Table.KeyNo, Primary_Table.LogDate, Primary_Table.Totincome, Primary_Table.Pname, Primary_Table.PAddr1, Primary_Table.PAddr2, Primary_Table.PCity, Primary_Table.PSt, Primary_Table.PZip, Primary_Table.PHP, Primary_Table.SSO, Prim_Lines_of_Trade.P_AD, Prim_Lines_of_Trade.P_last_rprtd, Prim_Lines_of_Trade.P_Bal, Prim_Lines_of_Trade.P_Mop, Prim_Lines_of_Trade.P_pymt, Prim_Lines_of_Trade.[1Narr], Prim_Lines_of_Trade.[2Narr], Prim_AA_Codes.Pdecl_1, Prim_AA_Codes.Pdecl_2, Prim_AA_Codes.Pdecl_3, Prim_AA_Codes.Pdecl_4<o:p></o:p>
FROM (Primary_Table INNER JOIN Prim_Lines_of_Trade ON Primary_Table.KeyNo = Prim_Lines_of_Trade.KeyNo) INNER JOIN Prim_AA_Codes ON Prim_Lines_of_Trade.KeyNo = Prim_AA_Codes.KeyNo<o:p></o:p>
WHERE (((Prim_Lines_of_Trade.P_last_rprtd)>Date()-60) AND ((Prim_Lines_of_Trade.P_Mop)<"08"));<o:p></o:p>
<o:p></o:p>