W
W
WebAnalytics12019-10-16 18:14:31
Transact SQL
WebAnalytics1, 2019-10-16 18:14:31

SQL query to display all orders with a specific set of products?

MS SQL server
Table with products and order numbers to which they belong
5da7336455045124171133.jpeg
. It is necessary to get only orders highlighted in yellow by a query

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2019-10-16
@WebAnalytics1

SELECT Таблица_1.[ID заказа]
  FROM Таблица AS Таблица_1 
    INNER JOIN Таблица AS Таблица_2 ON Таблица_1.[ID заказа] = Таблица_2.[ID заказа]
  WHERE (Таблица_1.[ID товара] = 'Товар 1') AND (Таблица_2.[ID товара] = 'Товар 2')

There was already a question about garages, where there are all three brands of cars, there were respectively three aliases for the filter.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question