这两个存储过程都在我的 MySQL 5.1.73 服务器中编译:
delimiter $$
CREATE PROCEDURE get_admins()
BEGIN
SELECT *
FROM Accounts
INNER JOIN LINK_Account_Status ON Accounts.account_id=LINK_Account_Status.account_id
AND LINK_Account_Status.active_ind=1
WHERE Accounts.active_ind=1
AND Accounts.`type`='admin';
END $$
delimiter ;
delimiter $$
CREATE PROCEDURE get_admins2(
IN p_type varchar(50)
)
BEGIN
SELECT *
FROM Accounts
INNER JOIN LINK_Account_Status ON Accounts.account_id=LINK_Account_Status.account_id
AND LINK_Account_Status.active_ind=1
WHERE Accounts.active_ind=1
AND Accounts.`type`=p_type;
END $$
delimiter ;
执行CALL get_admins();
返回我期望的结果。
执行CALL get_admins2('admin');
错误:
错误代码:1267。操作“=”的排序规则(utf8_general_ci,IMPLICIT)和(utf8_unicode_ci,IMPLICIT)的非法混合
细心的响应者会注意到两个结果查询之间没有功能差异。我已经仔细检查了Accounts.type
它确实是 a varchar(50)
(即使它是不幸命名的)。
山姆山这里发生了什么?