I have 4 tables. suppose the list table is a collection of unique data, then there are 3 other tables, each of which has data where not all of the values are in the list table.
list |
---|
aa |
bb |
cc |
dd |
ee |
ff |
gg |
hh |
ii |
jj |
group_1 |
---|
aa |
cc |
ff |
hh |
group_2 |
---|
aa |
bb |
cc |
ee |
jj |
group_3 |
---|
aa |
bb |
dd |
I want to use SQL pass-through in ms. access to retrieve the value that matches the value in the table list. while for the appropriate value, it is left blank. so that the output you want to produce looks like this:
list | group_1 | group_2 | group_3 |
---|---|---|---|
aa | aa | aa | aa |
bb | bb | bb | |
cc | cc | cc | |
dd | dd | ||
ee | ee | ||
ff | ff | ||
gg | |||
hh | hh | ||
ii | |||
jj | jj |
I’ve tried using the IN function, but I got an error instead. Then I tried to use group by, but what appears is only the values that are between the 2 tables, the empty values do not appear. Sorry for my bad English. please help guys.
Advertisement
Answer
Try below query-
SELECT tblList.list, tblGroup_1.group_1, tblGroup_2.group_2, tblGroup_3.group_3 FROM ((tblList LEFT JOIN tblGroup_1 ON tblList.list = tblGroup_1.group_1) LEFT JOIN tblGroup_2 ON tblList.list = tblGroup_2.group_2) LEFT JOIN tblGroup_3 ON tblList.list = tblGroup_3.group_3;
You can simply make query in design view using LEFT JOIN
.