GROUP BY 出錯
代碼為:
SELECT goods_id , goods_name FROM tdb_goods GROUP BY goods_name;
報錯為:
ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause and con
tains nonaggregated column 't2.tdb_goods.goods_id' which is not functionally depen
dent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_g
roup_by
2016-12-20
sql_mode 的問題,改一下應該就可以了。
http://blog.csdn.net/wulantian/article/details/8905573
2017-02-09
我改成這個模式然后GROUP BY 就可以正常使用了?。?!
2016-12-20
mysql> DELETE t1 FROM tdb_goods AS t1 LEFT JOIN (SELECT ANY_VALUE(goods_id) AS goo
ds_id , goods_name FROM tdb_goods GROUP BY goods_name HAVING COUNT(goods_name)>1)
AS t2
? ? -> ON t1.goods_name = t2.goods_name WHERE t1.goods_id > t2.goods_id;
Query OK, 2 rows affected (0.08 sec)
不用改sql_mode