Check if in a table

munday63

Registered User.
Local time
Today, 16:58
Joined
Feb 22, 2005
Messages
18
I have two tables:

one with all the policy numbers, and another with a few of the policy numbers. How would i make a query, that each policy number is in the other table, then it returns "Yes", otherwise it returns "no"?
 
Use a duplicates query in the query wizard

Col
 
If table1 has them all and table2 has the few then left join table1 and 2 on name and anew field InBoth:IIf(IsNull(Table2.name),"NO","YES")

The sql will look like


SELECT Table1.name, IIf(IsNull([table2].[name]),"NO","YES") AS inboth
FROM Table1 LEFT JOIN Table2 ON Table1.name = Table2.name;

Brian
 

Users who are viewing this thread

Back
Top Bottom