steve.g
steve.g

Reputation: 115

five table join?

I am trying to join 5 tables so that I can create an invoice for my customers. The 5 tables are named; Customer, Employee, Sale, Sale_product and Product. The Customer and Employee tables are linked to the Sale via a one to many relationship. The Sale table is then linked to Sale_product table with a one to many relationship followed by sale_product being linked in the same way.

Here is my from statement which is giving me the problem.

from
INNER JOIN Sale_Product 
ON product.prod# = Sale_Product.prod#
INNER JOIN Sale 
ON sale.inv# = sale_product.inv#
INNER JOIN customer
ON customer.cust# = sale.cust#
INNER join employee
ON employee.emp# = sale.emp#    

I would really appreciate some help understanding this.

Upvotes: 0

Views: 244

Answers (3)

Neil
Neil

Reputation: 55432

It looks as if you forgot to name the product table in your query, it belongs in the FROM clause:

FROM product

Upvotes: 0

Tony Hopkinson
Tony Hopkinson

Reputation: 20330

You want something like

Select * From ATable Join BTable on ATable.ID = BTable.ID

ie you put one of your five tables after from and then join to the other four.

Upvotes: 0

Gordon Linoff
Gordon Linoff

Reputation: 1271111

Either add a table after the "from" or remove the "inner join" before Sale_Product.

Upvotes: 2

Related Questions