为了账号安全,请及时绑定邮箱和手机立即绑定

DELETE时出错,我的MySQL是5.7.14

mysql> DELETE t1 FROM tdb_goods AS t1 LEFT JOIN (SELECT MIN(goods_id),goods_name FROM tdb_goods GROUP BY goods_name HAVING count(goods_name) >= 2) AS t2 ON t1.goods_name = t2.goods_name WHERE t1.goods_id > t2.goods_id;
ERROR 1054 (42S22): Unknown column 't2.goods_id' in 'where clause'

上面是语句和出错,请问要怎么解决?

正在回答

2 回答


根据本吊的猜测你的列名不是goods_id

0 回复 有任何疑惑可以回复我~

原句是:

delete t1 from tdb_goods as t1 left join (select goods_id,goods_name from tdb_goods group by goods_name having count(goods_name)>=2) as t2 on t1.goods_name=t2.goods_name where t1.goods_id>t2.goods_id;  

你多了一个函数 MIN(goods_id)

0 回复 有任何疑惑可以回复我~
#1

gakeez 提问者

也是不行的
2016-09-29 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
与MySQL的零距离接触
  • 参与学习       396886    人
  • 解答问题       3353    个

本课程涵盖全部MySQL数据库的基础,学习MySQL数据库的基础知识

进入课程

DELETE时出错,我的MySQL是5.7.14

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信