Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

help with joins (inner / outer)

Posted on 2008-10-22
5
Medium Priority
?
263 Views
Last Modified: 2010-03-20
So here's the scenario, I'm combining two tables to create a third table.  They are joined by an ID field.
Sometimes Table B does not have the ID to coincide with Table A, which is fine.  The record will still show in the new table, with a blank field from Table B. (inner join)

However, sometimes the ID is missing from Table A, and it is in Table B.  (outer join).  I need to be able to see these records as well on the final table.  But instead the Table A field will be blank.

Example:

TABLE A
ID    FIELD A
1     Hello
3     Name
4     Is
5     Sam

Table B
ID    FIELD B
1     The
2     Fox
3     Jumped
5     Fence

In the end I want to see:

ID      FIELD A          FIELD B
1       Hello               The
2                              Fox
3       Name              Jumped
4       Is
5       Sam                Fence

is this possible, or perhaps I need to do two queries?
0
Comment
Question by:NO_CARRIER
  • 3
5 Comments
 
LVL 16

Expert Comment

by:brad2575
ID: 22777784
Select FieldList
From TableA A Full Outer Join TableB B ON A.ID = B.ID

This will get all data from BOTH tables.
0
 
LVL 1

Author Comment

by:NO_CARRIER
ID: 22778048
Thanks, I'll try it.  Never even knew there was such a thing as full outer join. :)
0
 
LVL 1

Author Comment

by:NO_CARRIER
ID: 22778366
I don't think this will work in Acces.   Seems like it only understand LEFT, RIGHT and INNER joins.
0
 
LVL 22

Accepted Solution

by:
dportas earned 500 total points
ID: 22778633
You'll have to union a pair of joins:

SELECT A.ID, A.A, B.B
FROM TableA AS A LEFT OUTER JOIN TableB AS B ON A.ID = B.ID
UNION
SELECT B.ID, A.A, B.B
FROM TableB AS B LEFT OUTER JOIN TableA AS A ON A.ID = B.ID;

Alternatively, you might want to get a better DBMS. :)
0
 
LVL 1

Author Comment

by:NO_CARRIER
ID: 22779502
Thanks...
Wish we could get a better DBMS---but I don't make the decisions, I just work here. :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Recursive SQL is one of the most fascinating and powerful and yet dangerous feature offered in many modern databases today using a Common Table Expression (CTE) first introduced in the ANSI SQL 99 standard. The first implementations of CTE began ap…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question