当我包含WHERE LIKE时,MySql语句不返回任何结果。

声明:

SELECT aes_decrypt(SchoolName, 'MyString') as SchoolName from SchoolList Where aes_decrypt(SchoolName, 'MyString') LIKE '% Part of School Name Here%'


如果我删除LIKE则可以

SELECT aes_decrypt(SchoolName, 'MyString') as SchoolName from SchoolList Where aes_decrypt(SchoolName, 'MyString') = 'School Name Here'

最佳答案

您需要将aes_decrypt的结果强制转换为char才能使用LIKE运算符:

SELECT aes_decrypt(SchoolName, 'MyString') as SchoolName
from SchoolList
Where cast(aes_decrypt(SchoolName, 'MyString') as CHAR) LIKE '% Part of School Name Here%'


请参见以下示例:https://www.db-fiddle.com/f/m1ynqMzVqSs5yTeTmrqUbP/1

10-06 14:03