Link to home
Start Free TrialLog in
Avatar of engineroom
engineroom

asked on

INNER JOIN triple help...

hey all, i'm using an inner join query and it does what i want it to do, i need to add another join to get info from another table and i can't seem to get it right, i thought i had it at one point but it didn't work. here's the query that does what i want it to do....

SELECT loanType,creditHistory from (leads INNER JOIN leads_link ON leads_link.leadID=leads.leadID) INNER JOIN brokers on leads_link.brokerID=brokers.brokerID where leads.dateON between #1/16/2007# And #2/1/2007#

Now, i need to add to this a sales table which shares the salesID in the brokers table. So here's the structure for that...

Sales          brokers
--------     ---------------
salesID        salesID

So here's what i tried to do, but it didn't work...

SELECT  sales.salesID, sales.fname, loanType,creditHistory from ((leads INNER JOIN leads_link ON leads_link.leadID=leads.leadID) INNER JOIN brokers ON leads_link.brokerID=brokers.brokerID) INNER JOIN sales ON brokers.salesID=sales.salesID) where leads.dateON between #1/16/2007# And #2/1/2007#

Am i close? I'm using MS Access. Thanx all. Hope this makes sense.

SOLUTION
Avatar of Preece
Preece
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
And, actually, I've never used parenthesis with joins.  This is the first time that I've seen that.  Maybe other experts can comment...

Preece
Avatar of engineroom
engineroom

ASKER

okay, that worked but didn't render any results.... don't get it.. the original query gives me 16 results, this should do the same. What's wrong?
Are the salesID's populated in your brokers table for the records in that date range?  Also, are these possibly leads that have not yet resulted in sales, hence no salesID associated yet?

Preece
Hmmm...try switching the order of tables in the last two joins:

INNER JOIN brokers ON leads_link.brokerID=brokers.brokerID) INNER JOIN sales ON brokers.salesID=sales.salesID)

INNER JOIN brokers ON brokers.brokerID = leads_link.brokerID) INNER JOIN sales ON sales.salesID = brokers.salesID)

Preece
That didn't do anything. :o\
Anyone else? FtB? acperkins?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well,engineroom, any luck with any of the above?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Badotz
That didn't return any results.

@YZlat
Syntax error (operator missing)

@acperkins
Syntax error (operator missing)

Thanx guys. for everything.
okay guys, i think i know what's going on. All the code provided, including mine wasn't bad. The results are returning ID's that don't exist anymore, therefore, no results. Thanx all for your help and for your patience. I'm gonna split the points between all of ya'll.

er