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!

joining two tables via multiple fields

Status
Not open for further replies.

PAULCALLAGHAN

Technical User
Sep 4, 2001
165
CA
I have Access 2000. I would like to create a query based on data from two tables but having trouble joining them up.

In table 1 I have ORDNUM which is 10 characters in length. In table 2 I have 3 fields that relate back to this, ORDER (the first 6 characters), LINE (the next 2 characters) and DELIV (the final 2 characters).

Can someone please help me to write the SQL code to properly "join" these tables by connecting these fields together?
 
this may work:
Code:
SELECT * FROM tbl1 INNER JOIN (SELECT ORDER & LINE & DELIV As ORDERNUM) As B on tbl1.ORDNUM = B.ORDERNUM



Leslie
 
Thanks lespaul, but now I'm getting a syntax error. Can you please explain what it is you are doing? Maybe I can test something slightly different.

Any suggestions?
 
Something like this ?
SELECT *
FROM tbl1,tbl2
WHERE tbl1.ORDNUM=tbl2.ORDER & tbl2.LINE & tbl2.DELIV
;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I forgot the FROM clause in the INNER JOIN SELECT:
Code:
SELECT * FROM tbl1 INNER JOIN (SELECT ORDER & LINE & DELIV As ORDERNUM FROM tbl2) As B on tbl1.ORDNUM = B.ORDERNUM


Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top