Depending on how you store this name, "John". If this is ONLY a thing in a certain area, you can do something like
SELECT ... FROM sometable WHERE cryptedfirstname = AES_ENCRYPT('John', $key)
If “John” is part of a larger line (“John Doe” or “King John, Ruler of the Universe”), then you will have to decrypt the full field and match it
SELECT ... FROM sometime WHERE INSTR(AES_DECRYPT(cryptedFULLame, $key), 'John') > 0
Please note that I am embedding the decryption key in the request. A bad idea for a production system, but this is just an example.
You cannot do something like:
... WHERE INSTR(cryptedFULLname, AES_ENCRYPT('John', $key))
due to how AES and most other useful / decent cryptosystems work.
source share