Click here to Skip to main content
16,020,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to scan each record in the table tblTestCodeFavorites to ensure the value in the field TestCode exists in the table testCodes. If the value in tblTestCodeFavorites.TestCode does not exist in testCodes.SomeField, then I need to perform some processing on that tblTestCodeFavorites record (or records).
Posted
Updated 28-Apr-11 6:58am
v2
Comments
Corporal Agarn 28-Apr-11 12:29pm    
I suggest you
1) rewrite the title
2) rewrite the question
3) show what you have tried

Hint JOIN
AspDotNetDev 28-Apr-11 12:59pm    
I updated your question to have a more succinct title and a more descriptive explanation. Please add any code you've tried and ask a specific question about the problem you are having. Right now you are asking us to give you code... we need to see that you've already tried to do this yourself.

1 solution

SQL
SELECT tcf.*
FROM tblTestCodeFavorites tcf
    LEFT JOIN tblTestCodes tc ON tcf.TestCode = tc.SomeField
WHERE tc.SomeField IS NULL; 


Above SQL statement will fetch you all the records in table tblTestCodeFavorites that don't have values in column TestCode that would match column SomeField in table tblTestCodes. Loop through these rows and do whatever processing your heart may desire.

Best Regards,

-MRB
 
Share this answer
 
Comments
stevenandler 29-Apr-11 15:21pm    
Thank you Manfred. This works great!
Manfred Rudolf Bihy 2-May-11 6:40am    
You're welcome!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900