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

How to add a Table to an existing SQL statement 1

Status
Not open for further replies.

rwn

Technical User
Dec 14, 2002
420
US
I have this existing functional SQL and need to add the Customer Table to this SQL:
The current SO_Header table has a field called "SO_Header.Customer" and the Customer table has a field called "Customer.Customer" these to need to be linked in the below SQL.


sql = sql & "FROM SO_Header INNER JOIN (SO_Detail LEFT JOIN Material ON SO_Detail.Material = Material.Material) " _
& "ON SO_Header.Sales_Order = SO_Detail.Sales_Order " _
& "WHERE SO_Header.Status IN('Hold', 'Open') "
 
What type of link?

LEFT, RIGHT, INNER?

Code:
sql = sql & "FROM SO_Header INNER JOIN (SO_Detail LEFT JOIN Material ON SO_Detail.Material = Material.Material) " _
& "ON SO_Header.Sales_Order = SO_Detail.Sales_Order " _
& "INNER JOIN Customer ON SO_Header.Customer = Customer.Customer " _
& "WHERE SO_Header.Status IN('Hold', 'Open') "

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
INNER JOIN is PERFECT! Thank you
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top