MySql: Column 'XXXX' in field list is ambiguous 错误
[Err] 1052 - Column 'XXXX' in field list is ambiguous
例如:
SELECT
id,
a.name,
price,
`describe`,
schoolid,
`subject`
FROM
tariffpackages a,
schooluser b
WHERE
a.schoolid=b.Schoolid
出现错误:
[SQL]SELECT
id,
a.name,
price,
`describe`,
schoolid,
`subject`
FROM
tariffpackages a,
schooluser b
WHERE
a.schoolid=b.Schoolid
[Err] 1052 - Column 'schoolid' in field list is ambiguous
原因是:
tariffpackages表和schooluser表中都有schoolid字段。
解决方法:
SELECT
id,
a.name,
price,
`describe`,
a.schoolid,
`subject`
FROM
tariffpackages a,
schooluser b
WHERE
a.schoolid=b.Schoolid
本文来自博客园,作者:邓晓晖,转载请注明原文链接:https://www.cnblogs.com/isdxh/p/5627195.html