Querying Data that is not in each table (1 Viewer)

jeff3457

Registered User.
Local time
Today, 11:47
Joined
Oct 30, 2019
Messages
25
Hi,

I have built a query from 4 different tables. Simply, I want to maintain the data from the first table and add in data if present from the other 3 tables.

My first table has all employee numbers, I am using that to link to the other 3 tables. My issue is not every employee shows in the other 3 tables. I believe that is causing my query to drop that employee. Is there a way to fix this? I would like my query to still show every employee and just provide a 0 or no value if they are not present in one of the tables.
 

Isaac

Lifelong Learner
Local time
Today, 08:47
Joined
Mar 14, 2017
Messages
8,777
Look into Left Joins rather than Inner Joins.
 

jeff3457

Registered User.
Local time
Today, 11:47
Joined
Oct 30, 2019
Messages
25
Look into Left Joins rather than Inner Joins.
Thank you! That worked and was much simpler than I anticipated.

Is there a way to have it show any absent data as zero? It isn't needed but would be nice to add.
 

Isaac

Lifelong Learner
Local time
Today, 08:47
Joined
Mar 14, 2017
Messages
8,777
Great! Glad it helped.

You can create a new column like this:

DataIsAbsent: iif(isnull([othertable].[fieldyoujoinedon]),0,1)

Which would put a 0 if the other table didn't have it
edited the 1 vs. 0 reversal
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 23:47
Joined
May 7, 2009
Messages
19,237
simply use:

Absent: Nz([TableName.[FieldName], 0)
 

Users who are viewing this thread

Top Bottom