V
V
Vlad2017-10-05 16:53:26
MySQL
Vlad, 2017-10-05 16:53:26

How to write a SQL Join query?

Please help me to create a query to get the lowest price value among all values ​​that have category_id = 10
id = product_id in another table

Table 1
id - price
1 - 100
2 - 300
3 - 50
Table 2
product_id - category_id
1 - 10
2 - 10
3 - 11

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2017-10-05
@Sc0undRel

SELECT
  min(price)
FROM
  table1
WHERE
  id IN (
    SELECT DISTINCT
      (product_id)
    FROM
      table2
    WHERE
      category_id = 10
  )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question