问题
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