Mega Code Archive

 
Categories / MySQL / Function
 

DECODE(encrypted string, key)

mysql> mysql> CREATE TABLE UserAccounts     -> (     ->     UserID SMALLINT NOT NULL PRIMARY KEY,     ->     Password VARCHAR(20) NOT NULL     -> ); Query OK, 0 rows affected (0.00 sec) mysql> INSERT INTO UserAccounts VALUES     -> (101, ENCODE('pw101', 'key101')); Query OK, 1 row affected (0.00 sec) mysql> mysql> SELECT * FROM Users; mysql> mysql> SELECT UserID, DECODE(Password, 'key101') AS Password     -> FROM UserAccounts; +--------+----------+ | UserID | Password | +--------+----------+ |    101 | pw101    | +--------+----------+ 1 row in set (0.00 sec) mysql> mysql> drop table UserAccounts; Query OK, 0 rows affected (0.00 sec) mysql>