The error message indicates that there is an ambiguity in the SQL query in the 'StaffMapper.xml' file. Specifically, the 'staffid' column in the WHERE clause is ambiguous, meaning that it is not clear which table's 'staffid' column should be used.

To resolve this issue, you need to specify the table from which the 'staffid' column should be used in the WHERE clause. You can do this by prefixing the 'staffid' column with the table name or table alias.

For example, if the 'staffid' column belongs to the 'staff' table, you can modify the SQL query as follows:

SELECT count(0)
FROM (
    SELECT staff.staffid, staff.staffname, staff.idcard, staff.address, staff.phone, staff.entrytime, staff.leavetime, staff.state, branch.branchname, department.deptname, role.rolename
    FROM staff
    JOIN branch ON staff.branchid = branch.branchid
    JOIN department ON staff.deptid = department.deptid
    JOIN role ON staff.roleid = role.roleid
    WHERE staff.staffid = ? LIKE CONCAT('%',?,'%') AND staff.state = 0
) tmp_count

By explicitly specifying the table origin of the 'staffid' column in the WHERE clause, you eliminate the ambiguity and resolve the error.

SQL Ambiguity Error: 'staffid' Column in WHERE Clause

原文地址: https://www.cveoy.top/t/topic/hwOS 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录