我有一个查询:
SELECT u.user_id, f.eye_color, c.rating
FROM
user u LEFT JOIN connection c ON u.user_id = c.connection_user_id,
user_field f,
search s
WHERE
s.search_id = 1 AND
u.user_id = f.user_id AND
s.user_id != u.user_id
GROUP BY
u.user_id;
这是它显示的错误
错误代码:1055。SELECT列表的表达式#51不在GROUP BY子句中,并且包含非聚合列'sos.c.rating',该列在功能上不依赖于GROUP BY子句中的列;这与sql_mode = only_full_group_by
不兼容
答案 0 :(得分:0)
您可以在下面尝试
您将显式联接和隐式联接混合在一起,并且GROUP BY是不必要的,因为您不聚合任何列
SELECT u.user_id, f.eye_color, c.rating
FROM
user u LEFT JOIN connection c ON u.user_id = c.connection_user_id,
left join user_field f on u.user_id = f.user_id
left join search s on s.user_id != u.user_id
WHERE
s.search_id = 1
答案 1 :(得分:0)
您必须在分组依据
中添加所有可更改的列选择u.user_id,f.eye_color,c.rating
从
用户u左联接连接c ON u.user_id = c.connection_user_id,
user_field f,
搜索
在哪里
11
</td>
<td class="no-wrap currency-name" data-sort="TRON">
<img data-src="https://s2.coinmarketcap.com/static/img/coins/16x16/1958.png" class="logo-sprite lazyload" alt="TRON" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" height="16" width="16">
组别
s.search_id = 1 AND
u.user_id = f.user_id AND
s.user_id != u.user_id