Using encode function with insert statement : Insert « Insert Update Delete « MySQL Tutorial






mysql>
mysql>
mysql> CREATE TABLE UserAccounts
    -> (
    ->    UserID SMALLINT NOT NULL PRIMARY KEY,
    ->    Password VARCHAR(20) NOT NULL
    -> );
Query OK, 0 rows affected (0.02 sec)

mysql>
mysql>
mysql> INSERT INTO UserAccounts VALUES (101, ENCODE('pw101', 'key101'));
Query OK, 1 row affected (0.00 sec)

mysql>
mysql> select * from UserAccounts;
+--------+----------+
| UserID | Password |
+--------+----------+
|    101 | ?*       |
+--------+----------+
1 row in set (0.00 sec)

mysql>
mysql>
mysql> drop table UserAccounts;
Query OK, 0 rows affected (0.00 sec)

mysql>








7.1.Insert
7.1.1.INSERTing data
7.1.2.Insert more than one rows in a single insert statement
7.1.3.Insert two rows with one insert statement
7.1.4.Do calculation in the insert statement referencing the column name
7.1.5.Insert quotation marks
7.1.6.Insert NULL to a NOT NULL column
7.1.7.Insert with set statement
7.1.8.Use the DEFAULT in the insert statement
7.1.9.Using encode function with insert statement