当我包含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'
答案 0 :(得分:1)
您需要将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