mysql查询报错 错误代码: 3065,百度没找到这个错误,而且非常的奇葩,来看

MySql 码拜 8年前 (2016-02-13) 2410次浏览
错误:
错误代码: 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里面导致的把。
本人刚才在其他数据库上试了一下,也是报错的。

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明mysql查询报错 错误代码: 3065,百度没找到这个错误,而且非常的奇葩,来看
喜欢 (0)
[1034331897@qq.com]
分享 (0)