Aaron
Aaron

Reputation: 10858

Using AES_DECRYPT with SELECT *

Is it possible to select all records and decrypt them using the asterisk with the AES_DECRYPT function? This is what I want to be able to do:

SELECT AES_DECRYPT(*, SOMESTATICKEY) FROM some_table

EDIT: I guess I should clarify my question since I know what I'm asking doesn't work. What I want to know is if there is any other way syntactically or functionally to do this.

Upvotes: 1

Views: 6120

Answers (1)

Saju
Saju

Reputation: 3267

If you have a look at this link about SELECT Syntax for mysql
http://dev.mysql.com/doc/refman/5.0/en/select.html
You can see that after The SELECT verb the command is expecting a select_expr or a list of select_expr

which means you have to issue commands in this form.

SELECT AES_DECRYPT(Field1, SOMESTATICKEY),
       AES_DECRYPT(Field2, SOMESTATICKEY),
       AES_DECRYPT(Field3, SOMESTATICKEY)
FROM some_table

Moreover, AES_DECRYPT() function is expecting a string as its first parameter not a list.

So the answer is clearly No

Upvotes: 3

Related Questions