Mysql 如何在SQL中获取整个店铺列表

Mysql 如何在SQL中获取整个店铺列表,mysql,sql,database,Mysql,Sql,Database,我想检查每个商店的平均分数 我的“商店”桌子是 我的“订单”表是 我的SQL是: SELECT a.id,a.name,AVG(b.point) as point from shop a LEFT JOIN order b on a.id=b.shop_id WHERE b.point<>0 GROUP BY(b.shop_id) 选择a.id、a.name、平均值(b.point)作为点 从a店 a.id=b.shop\U id上的左连接订单b b.0点在哪里 分组依据(b

我想检查每个商店的平均分数

我的“商店”桌子是

我的“订单”表是

我的SQL是:

SELECT a.id,a.name,AVG(b.point) as point
from shop a
LEFT JOIN order b on a.id=b.shop_id
WHERE b.point<>0
GROUP BY(b.shop_id) 
选择a.id、a.name、平均值(b.point)作为点
从a店
a.id=b.shop\U id上的左连接订单b
b.0点在哪里
分组依据(b.车间标识)
但此SQL只能检查“订单”表中的店铺点


如何使用SQL获取完整的店铺列表?

请尝试一下:

SELECT
    a.id,
    a.NAME,
    AVG(b.point) AS point
FROM
    shop a
LEFT JOIN `ORDER` b ON a.id = b.shop_id AND b.point <> 0
GROUP BY a.id
选择
a、 身份证,
a、 名字,
平均值(b点)作为点
从…起
购物
左连接a.id=b.shop\u id和b.point 0上的'ORDER`b
按a.id分组

由于
b.shop\u id
可以是
NULL
,因此您需要按
a.id
进行分组,以便获得所有店铺id的结果。

请提供数据以了解您的答案,这是对我问题的完美回答