Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

join expressions? multiple conditions. 1

Status
Not open for further replies.

imstillatwork

IS-IT--Management
Sep 26, 2001
1,605
US
in other dbs, this works just fine:

SELECT fields...
FROM table1 AS t1
LEFT JOIN table2 AS t2
ON t2.table1_id = t2.id AND t2.type = 3

I get join expression not supported errors.

I need to provide more then one condition for the join, I generaly use mySQL, but this project is stuck to access, which is fine by me, it's just been a while.

thank!!




Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Try changing your SQL statement to this:

SELECT fields...
FROM table1 AS t1
LEFT JOIN table2 AS t2
ON t1.id = t2.id AND t2.type = 3


Bob
 
Your join condition doesn't mention any fields from Table1.
Code:
SELECT fields...
FROM table1 AS t1
LEFT JOIN table2 AS t2
ON [COLOR=red]t2[/color].table1_id = [COLOR=red]t2[/color].id AND [COLOR=red]t2[/color].type = 3
 
A starting point in JetSQL compatible syntax:
SELECT fields...
FROM table1 AS t1 LEFT JOIN (
SELECT fields... FROM table2 WHERE type = 3
) AS t2 ON t1.SomeID = t2.AnotherID

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
there was indeed a typo in my question

SELECT fields...
FROM table1 AS t1
LEFT JOIN table2 AS t2
ON t2.table1_id = t1.id AND t2.type = 3

I'll check the res of your posts also, thanks!


Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
HOw about this one?

SELECT fields...
FROM table1 AS t1
LEFT JOIN table2 AS t2
ON t2.table1_id = t1.id
WHERE t2.type = 3

 
WHERE t2.type = 3
Doing that defeats the OUTER join purpose ...
With Kevin correction:
SELECT fields...
FROM table1 AS t1 LEFT JOIN (
SELECT fields... FROM table2 WHERE type = 3
) AS t2 ON t1.id = t2.table1_id

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
PHV, you are right, thanks for the correction.

SELECT fields... FROM table2 WHERE type = 3 is considered a derived table correct?
 
yes, the join table needs the condition, not the final row. otherwise a table1 row with no matching table 2 contisions will not return a row, but I need all the table one rows no matter what.

thanks PHV!

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
is considered a derived table
I personally say an inline view
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top