MYSQL delete执行异常Column 'PID' in where clause is ambiguous

  • 内容
  • 评论
  • 相关

mysql delete执行错误Column 'PID' in where clause is ambiguous
delete a,b, from a,b where PID in (6,7,8);

两个表中都有PID字段,A.PID是主键,B.PID是无符号int字段记录此数据属于A表哪个主键。我想用上面的命令删除a,b两表中,所有PID值为6,7,8的数据行,结果失败了。。请问正确语句是什么?

------解决方案--------------------
查询分析器分不清pid是哪个表的 如果你两个表都要 请在where条件当中明确你的条件
------解决方案--------------------
delete a,b, from a,b where a.PID in (6,7,8);
------解决方案--------------------
delete a,b from a,b where a.pid in(6,7,8);
------解决方案--------------------
DELETE a,b FROM a,b WHERE a.pID IN (6,7,8);
------解决方案--------------------

探讨

DELETE a,b FROM a,b WHERE a.pID IN (6,7,8);

------解决方案--------------------
DELETE a,b FROM a,b WHERE a.pID IN (6,7,8) OR b.PID IN (6,7,8);
------解决方案--------------------

探讨

DELETE a,b FROM a,b WHERE a.pID IN (6,7,8);

原创文章,转载请注明: 转载自搞代码

本文链接地址: MYSQL delete执行异常Column 'PID' in where clause is ambiguous

微信支付二维码

微信 赏一包辣条吧~

支付宝支付二维码

支付宝 赏一听可乐吧~

评论

0条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注