bbwolff
bbwolff

Reputation: 99

Query to show whether an entry from one table is in the other

This might be simple, but I can't figure it out. In one table i have all the people, in the other some event with that people. I'd like to make a query where in first coloumn I get a list of people from table one and in the other a simple yes/no, based on whether their ID is in table two.

Upvotes: 0

Views: 29

Answers (1)

Cheetah
Cheetah

Reputation: 11

Open your query builder and ADD both tables (people and events).
Select fields from your PEOPLE table and at least one field from your EVENTS table. They should be joined via the Primary Key of the People table. Right click on the join between the 2 tables and select JOIN PROPERTIES. Select "Include all records from PEOPLE and only those from EVENTS where joined fields are equal." Use this formula in your YES/NO field: IIF(isnull([eventField]),"NO","YES")

That is one way of doing it...

Upvotes: 1

Related Questions