mysql 想将某表的统计结果作为另外表的查询条件要怎么写
发布网友
发布时间:2022-04-08 09:14
我来回答
共1个回答
热心网友
时间:2022-04-08 10:43
SELECT
*
FROM
shop
WHERE
id IN (
SELECT
t1.id,
count(1) cnt
FROM
shop t1
LEFT JOIN goods t2 ON t1.id = t2.shop_id
WHERE
t1.address = '指定商铺地址'
GROUP BY
t1.id
HAVING
cnt > 100
) t
先获取满足指定商铺地址的商铺的商品数量信息,再根据id获取商铺信息