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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Join with 2 conditions

Status
Not open for further replies.

davida37

IS-IT--Management
May 10, 2006
113
GB
Hi there,

using Access 2003.

I am use to using T-SQL (sql server). I am having problems joining 2 tables with 2 conditions in the join. in t-sql the following would work fine:

SELECT
x,y,z
FROM
table1 INNER JOIN table2
on (table1.memberid = table2.memberid AND table1.Date = table2.Date)

the query works without the 2nd condition in the on clause. i.e.

SELECT
x,y,z
FROM
table1 INNER JOIN table2
on (table1.memberid = table2.memberid)


BUT fails with it - or asks for parameter inputs.

Please help.

thanks in advance.
david


 
This is because Date is a reserved word in Access.

Rename the column to something like InvoiceDate or RenewalDate in both columns, change the SQL then it will work fine.

John
 
Or maybe

SELECT
x,y,z
FROM table1 As T1 INNER JOIN table2 As T2 On
(T1.memberid = T2.memberid) AND
(T1.[Date] = T2.[Date])
 
thanks for your suggestions. Was actually a number of issues in the end - but now works.

thanks

FROM SalaryReport INNER JOIN EffectiveDate_Max ON (SalaryReport.EmployeeID=EffectiveDate_Max.EmployeeID) AND (SalaryReport.EffectiveDate=CDATE(EffectiveDate_Max.EffectiveDate));
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top