how to use Like statement to get encrypted value from a table in mysql?

做~自己de王妃 提交于 2021-01-06 11:31:26

问题


how to use like statement in encrypted column in mysql

i need to get user id from a table where username is like some value(user given input). but my username column is locally encrypted and stored in DB. Now, how to get the decrypt value from DB for using like statement. i am using Like statement in search method to get the values from the table that matches it, but values are encrypted in table.

For example: vi - 68726rgur4746r279267(encrypted type first name in db).

when i type vi in the search box everything that starts with word vi should be taken from the db.


回答1:


You can't search on an encrypted column without first decrypting it.

Select * From table
WHERE AES_DECRYPT(col_name,key_str) LIKE '%something%'


来源:https://stackoverflow.com/questions/34392192/how-to-use-like-statement-to-get-encrypted-value-from-a-table-in-mysql

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!