日期:2014-05-16  浏览次数:20963 次

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);