R
R
rklimcorp2017-02-02 16:21:00
MySQL
rklimcorp, 2017-02-02 16:21:00

MySql: How to make a selection from one table based on another?

Hello, there are 2 tables "Warehouses" and "Products" they are connected 1 to many, there can be several goods in one warehouse. What would be the correct query to pull out from the table all the warehouses in which there are more than 3 products? XXeS-yycOJk.jpg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2017-02-02
@rklimcorp

select
  w.name
from warehouse as w
inner join goods as g
  on w.id = g.warehouse_id
group by w.id
having count(g.id) > 3;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question