错误:
错误代码: 3065
Expression #2 of ORDER BY clause is not in SELECT list, references column “shopcs.pd.sorder” which is not in SELECT list; this is incompatible with DISTINCT
执行的sql:
SELECT DISTINCT b.goods_id AS b_goods_id,
pd.product_id AS pd_product_id,
pd.pkgnum AS pd_mkgnum,
eg.goods_id AS eg_goods_id,
eg.specs AS eg_specs,
eg.name AS eg_name,
eg.small AS eg_small,
ep.sn AS ep_sn
FROM es_product p
JOIN es_package_product pp
ON p.goods_id = 493
AND pp.product_id = p.product_id
AND pp.is_show = 1
JOIN es_goods b
ON b.goods_id = pp.goods_id
AND b.market_enable = 1
AND b.disabled = 0
JOIN es_package_product pd
ON pd.goods_id = b.goods_id
JOIN es_product ep
ON pd.product_id = ep.product_id
JOIN es_goods eg
ON eg.goods_id = ep.goods_id
AND eg.market_enable = 1
AND eg.disabled = 0
ORDER BY b.goods_id, pd.sorder;
错误代码: 3065
Expression #2 of ORDER BY clause is not in SELECT list, references column “shopcs.pd.sorder” which is not in SELECT list; this is incompatible with DISTINCT
执行的sql:
SELECT DISTINCT b.goods_id AS b_goods_id,
pd.product_id AS pd_product_id,
pd.pkgnum AS pd_mkgnum,
eg.goods_id AS eg_goods_id,
eg.specs AS eg_specs,
eg.name AS eg_name,
eg.small AS eg_small,
ep.sn AS ep_sn
FROM es_product p
JOIN es_package_product pp
ON p.goods_id = 493
AND pp.product_id = p.product_id
AND pp.is_show = 1
JOIN es_goods b
ON b.goods_id = pp.goods_id
AND b.market_enable = 1
AND b.disabled = 0
JOIN es_package_product pd
ON pd.goods_id = b.goods_id
JOIN es_product ep
ON pd.product_id = ep.product_id
JOIN es_goods eg
ON eg.goods_id = ep.goods_id
AND eg.market_enable = 1
AND eg.disabled = 0
ORDER BY b.goods_id, pd.sorder;
解决方案
50
应该是原因是 pd.sorder这列没有出现在select里面导致的把。
本人刚才在其他数据库上试了一下,也是报错的。
本人刚才在其他数据库上试了一下,也是报错的。