B
B
Bogdan Gerasimenko2021-04-15 17:18:27
SQL
Bogdan Gerasimenko, 2021-04-15 17:18:27

How to form a many to many SQL query?

Help to form a many to many query: you need to get the name of the product, the quantity and amount of the order (cheque table).

There are 3 tables:

  • product: id, name, price
  • sale: id, date, sum_sale
  • check: id_sale, id_product, count_product

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Bogdan Gerasimenko, 2021-04-16
@Kleindberg

So far I've found this solution:

SELECT
    p.name,
    c.count_product,
    p.price,
    s.sum_sale,
    s.date
FROM
    product AS p
INNER JOIN cheque AS c
ON
    p.id = c.id_product
INNER JOIN sale AS s
ON
    s.id = c.id_sale

D
Dimonchik, 2021-04-15
@dimonchik2013

JOIN

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question