A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Problem joining queries



 
 
Thread Tools Display Modes
  #1  
Old July 29th, 2007, 01:22 PM posted to microsoft.public.access.queries
skr
external usenet poster
 
Posts: 17
Default Problem joining queries

I’m having a problem joining three tables into one query. I can join the
Investment Table and the Fund Table but when I try to add the Institution
Table and run the query it comes back blank. Here are the details:

Table Funds:
Fund Number (primary key)
Fund Name

Table Institutions:
Institution Name (primary key)
Days to Use

Table Investments:
Investment Number (primary key)
Safekeeping Number
Institution Name
Fund Number
Face Amount
Interest Rate
Other Interest
Purchase Date
Maturity Date

The SQL for the two that join together OK is:

SELECT funds.[Fund Number], funds.[Fund Name], Investments.[Investment
Number], Investments.[Safekeeping Number], Investments.[Institution Name],
Investments.[Face Amount], Investments.[Interest Rate], Investments.[Other
Interest], Investments.[Purchase Date], Investments.[Maturity Date]
FROM funds INNER JOIN Investments ON funds.[Fund Number] = Investments.[Fund
Number];

The SQL when I add the Institution table is:

SELECT funds.[Fund Number], funds.[Fund Name], Investments.[Investment
Number], Investments.[Safekeeping Number], Investments.[Institution Name],
Investments.[Face Amount], Investments.[Interest Rate], Investments.[Other
Interest], Investments.[Purchase Date], Investments.[Maturity Date]
FROM Institutions INNER JOIN (funds INNER JOIN Investments ON funds.[Fund
Number] = Investments.[Fund Number]) ON Institutions.[Institution Name] =
Investments.[Institution Name];

I am pretty much self taught and haven’t focused to much on the SQL yet so
I’m hoping that somebody can look at this and explain to me what I’m doing
wrong.

Thanks,
Sue

  #2  
Old July 29th, 2007, 02:10 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 1,555
Default Problem joining queries

Sue

One approach might be to use LEFT (or RIGHT) joins. As I'm reading it, your
SQL looks for values when there is a match in all three tables.

You know your data better than we can ... do you have exact matches on join
keys across all three tables?

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

"skr" wrote in message
news
I’m having a problem joining three tables into one query. I can join the
Investment Table and the Fund Table but when I try to add the Institution
Table and run the query it comes back blank. Here are the details:

Table Funds:
Fund Number (primary key)
Fund Name

Table Institutions:
Institution Name (primary key)
Days to Use

Table Investments:
Investment Number (primary key)
Safekeeping Number
Institution Name
Fund Number
Face Amount
Interest Rate
Other Interest
Purchase Date
Maturity Date

The SQL for the two that join together OK is:

SELECT funds.[Fund Number], funds.[Fund Name], Investments.[Investment
Number], Investments.[Safekeeping Number], Investments.[Institution Name],
Investments.[Face Amount], Investments.[Interest Rate], Investments.[Other
Interest], Investments.[Purchase Date], Investments.[Maturity Date]
FROM funds INNER JOIN Investments ON funds.[Fund Number] =

Investments.[Fund
Number];

The SQL when I add the Institution table is:

SELECT funds.[Fund Number], funds.[Fund Name], Investments.[Investment
Number], Investments.[Safekeeping Number], Investments.[Institution Name],
Investments.[Face Amount], Investments.[Interest Rate], Investments.[Other
Interest], Investments.[Purchase Date], Investments.[Maturity Date]
FROM Institutions INNER JOIN (funds INNER JOIN Investments ON funds.[Fund
Number] = Investments.[Fund Number]) ON Institutions.[Institution Name] =
Investments.[Institution Name];

I am pretty much self taught and haven’t focused to much on the SQL yet so
I’m hoping that somebody can look at this and explain to me what I’m doing
wrong.

Thanks,
Sue


  #3  
Old July 29th, 2007, 02:32 PM posted to microsoft.public.access.queries
skr
external usenet poster
 
Posts: 17
Default Problem joining queries

Each Investment will be joined to a fund number and an institution. They all
three work together. I can't have an investment without a fund number or
institution.

"Jeff Boyce" wrote:

Sue

One approach might be to use LEFT (or RIGHT) joins. As I'm reading it, your
SQL looks for values when there is a match in all three tables.

You know your data better than we can ... do you have exact matches on join
keys across all three tables?

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

"skr" wrote in message
news
I’m having a problem joining three tables into one query. I can join the
Investment Table and the Fund Table but when I try to add the Institution
Table and run the query it comes back blank. Here are the details:

Table Funds:
Fund Number (primary key)
Fund Name

Table Institutions:
Institution Name (primary key)
Days to Use

Table Investments:
Investment Number (primary key)
Safekeeping Number
Institution Name
Fund Number
Face Amount
Interest Rate
Other Interest
Purchase Date
Maturity Date

The SQL for the two that join together OK is:

SELECT funds.[Fund Number], funds.[Fund Name], Investments.[Investment
Number], Investments.[Safekeeping Number], Investments.[Institution Name],
Investments.[Face Amount], Investments.[Interest Rate], Investments.[Other
Interest], Investments.[Purchase Date], Investments.[Maturity Date]
FROM funds INNER JOIN Investments ON funds.[Fund Number] =

Investments.[Fund
Number];

The SQL when I add the Institution table is:

SELECT funds.[Fund Number], funds.[Fund Name], Investments.[Investment
Number], Investments.[Safekeeping Number], Investments.[Institution Name],
Investments.[Face Amount], Investments.[Interest Rate], Investments.[Other
Interest], Investments.[Purchase Date], Investments.[Maturity Date]
FROM Institutions INNER JOIN (funds INNER JOIN Investments ON funds.[Fund
Number] = Investments.[Fund Number]) ON Institutions.[Institution Name] =
Investments.[Institution Name];

I am pretty much self taught and haven’t focused to much on the SQL yet so
I’m hoping that somebody can look at this and explain to me what I’m doing
wrong.

Thanks,
Sue



  #4  
Old July 29th, 2007, 07:40 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 1,555
Default Problem joining queries

Then I'm not sure why you are getting an empty result from your query.

If this were mine, I would first join only two tables and check on the
result. Then try the other two-table combination. Finally, I'd try the
'three-at-once' to see if anything changed.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/


"skr" wrote in message
...
Each Investment will be joined to a fund number and an institution. They

all
three work together. I can't have an investment without a fund number or
institution.

"Jeff Boyce" wrote:

Sue

One approach might be to use LEFT (or RIGHT) joins. As I'm reading it,

your
SQL looks for values when there is a match in all three tables.

You know your data better than we can ... do you have exact matches on

join
keys across all three tables?

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

"skr" wrote in message
news
I’m having a problem joining three tables into one query. I can join

the
Investment Table and the Fund Table but when I try to add the

Institution
Table and run the query it comes back blank. Here are the details:

Table Funds:
Fund Number (primary key)
Fund Name

Table Institutions:
Institution Name (primary key)
Days to Use

Table Investments:
Investment Number (primary key)
Safekeeping Number
Institution Name
Fund Number
Face Amount
Interest Rate
Other Interest
Purchase Date
Maturity Date

The SQL for the two that join together OK is:

SELECT funds.[Fund Number], funds.[Fund Name], Investments.[Investment
Number], Investments.[Safekeeping Number], Investments.[Institution

Name],
Investments.[Face Amount], Investments.[Interest Rate],

Investments.[Other
Interest], Investments.[Purchase Date], Investments.[Maturity Date]
FROM funds INNER JOIN Investments ON funds.[Fund Number] =

Investments.[Fund
Number];

The SQL when I add the Institution table is:

SELECT funds.[Fund Number], funds.[Fund Name], Investments.[Investment
Number], Investments.[Safekeeping Number], Investments.[Institution

Name],
Investments.[Face Amount], Investments.[Interest Rate],

Investments.[Other
Interest], Investments.[Purchase Date], Investments.[Maturity Date]
FROM Institutions INNER JOIN (funds INNER JOIN Investments ON

funds.[Fund
Number] = Investments.[Fund Number]) ON Institutions.[Institution

Name] =
Investments.[Institution Name];

I am pretty much self taught and haven’t focused to much on the SQL

yet so
I’m hoping that somebody can look at this and explain to me what I’m

doing
wrong.

Thanks,
Sue




  #5  
Old July 29th, 2007, 11:12 PM posted to microsoft.public.access.queries
skr
external usenet poster
 
Posts: 17
Default Problem joining queries

Yes, that's what I did. I can join the Investment table and the Fund Table
but I can't join the Institution table to either the Investment table nor the
Fund table and get anything in return.

"Jeff Boyce" wrote:

Then I'm not sure why you are getting an empty result from your query.

If this were mine, I would first join only two tables and check on the
result. Then try the other two-table combination. Finally, I'd try the
'three-at-once' to see if anything changed.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/


"skr" wrote in message
...
Each Investment will be joined to a fund number and an institution. They

all
three work together. I can't have an investment without a fund number or
institution.

"Jeff Boyce" wrote:

Sue

One approach might be to use LEFT (or RIGHT) joins. As I'm reading it,

your
SQL looks for values when there is a match in all three tables.

You know your data better than we can ... do you have exact matches on

join
keys across all three tables?

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

"skr" wrote in message
news I’m having a problem joining three tables into one query. I can join

the
Investment Table and the Fund Table but when I try to add the

Institution
Table and run the query it comes back blank. Here are the details:

Table Funds:
Fund Number (primary key)
Fund Name

Table Institutions:
Institution Name (primary key)
Days to Use

Table Investments:
Investment Number (primary key)
Safekeeping Number
Institution Name
Fund Number
Face Amount
Interest Rate
Other Interest
Purchase Date
Maturity Date

The SQL for the two that join together OK is:

SELECT funds.[Fund Number], funds.[Fund Name], Investments.[Investment
Number], Investments.[Safekeeping Number], Investments.[Institution

Name],
Investments.[Face Amount], Investments.[Interest Rate],

Investments.[Other
Interest], Investments.[Purchase Date], Investments.[Maturity Date]
FROM funds INNER JOIN Investments ON funds.[Fund Number] =
Investments.[Fund
Number];

The SQL when I add the Institution table is:

SELECT funds.[Fund Number], funds.[Fund Name], Investments.[Investment
Number], Investments.[Safekeeping Number], Investments.[Institution

Name],
Investments.[Face Amount], Investments.[Interest Rate],

Investments.[Other
Interest], Investments.[Purchase Date], Investments.[Maturity Date]
FROM Institutions INNER JOIN (funds INNER JOIN Investments ON

funds.[Fund
Number] = Investments.[Fund Number]) ON Institutions.[Institution

Name] =
Investments.[Institution Name];

I am pretty much self taught and haven’t focused to much on the SQL

yet so
I’m hoping that somebody can look at this and explain to me what I’m

doing
wrong.

Thanks,
Sue





  #6  
Old July 30th, 2007, 12:24 AM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 1,555
Default Problem joining queries

When this happens to me, it's generally because the data doesn't match up.

Have you "manually" confirmed that there are actually matching records
across all three?

Have you "manually" confirmed that the values in your second and third
tables actually match?

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

"skr" wrote in message
...
Yes, that's what I did. I can join the Investment table and the Fund

Table
but I can't join the Institution table to either the Investment table nor

the
Fund table and get anything in return.

"Jeff Boyce" wrote:

Then I'm not sure why you are getting an empty result from your query.

If this were mine, I would first join only two tables and check on the
result. Then try the other two-table combination. Finally, I'd try the
'three-at-once' to see if anything changed.

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/


"skr" wrote in message
...
Each Investment will be joined to a fund number and an institution.

They
all
three work together. I can't have an investment without a fund number

or
institution.

"Jeff Boyce" wrote:

Sue

One approach might be to use LEFT (or RIGHT) joins. As I'm reading

it,
your
SQL looks for values when there is a match in all three tables.

You know your data better than we can ... do you have exact matches

on
join
keys across all three tables?

--
Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

"skr" wrote in message
news I’m having a problem joining three tables into one query. I can

join
the
Investment Table and the Fund Table but when I try to add the

Institution
Table and run the query it comes back blank. Here are the

details:

Table Funds:
Fund Number (primary key)
Fund Name

Table Institutions:
Institution Name (primary key)
Days to Use

Table Investments:
Investment Number (primary key)
Safekeeping Number
Institution Name
Fund Number
Face Amount
Interest Rate
Other Interest
Purchase Date
Maturity Date

The SQL for the two that join together OK is:

SELECT funds.[Fund Number], funds.[Fund Name],

Investments.[Investment
Number], Investments.[Safekeeping Number],

Investments.[Institution
Name],
Investments.[Face Amount], Investments.[Interest Rate],

Investments.[Other
Interest], Investments.[Purchase Date], Investments.[Maturity

Date]
FROM funds INNER JOIN Investments ON funds.[Fund Number] =
Investments.[Fund
Number];

The SQL when I add the Institution table is:

SELECT funds.[Fund Number], funds.[Fund Name],

Investments.[Investment
Number], Investments.[Safekeeping Number],

Investments.[Institution
Name],
Investments.[Face Amount], Investments.[Interest Rate],

Investments.[Other
Interest], Investments.[Purchase Date], Investments.[Maturity

Date]
FROM Institutions INNER JOIN (funds INNER JOIN Investments ON

funds.[Fund
Number] = Investments.[Fund Number]) ON Institutions.[Institution

Name] =
Investments.[Institution Name];

I am pretty much self taught and haven’t focused to much on the

SQL
yet so
I’m hoping that somebody can look at this and explain to me what I

’m
doing
wrong.

Thanks,
Sue






 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:13 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.