Do calculation in the insert statement referencing the column name : Insert : Insert Update Delete MySQL TUTORIALS


MySQL TUTORIALS » Insert Update Delete » Insert »

 

Do calculation in the insert statement referencing the column name


mysql>
mysql> CREATE TABLE myTable(
    ->    ID TINYINT UNSIGNED NOT NULL DEFAULT 1,
    ->    Copyright YEAR,
    ->    Expire YEAR,
    ->    Name VARCHAR(50NOT NULL
    -> );
Query OK, rows affected (0.03 sec)

mysql>
mysql>
mysql> INSERT INTO myTable (ID, Copyright, Expire, Name)VALUES (1,1994,Copyright + Copyright,'A');
Query OK, row affected, warning (0.00 sec)

mysql>
mysql> select from myTable;
+----+-----------+--------+------+
| ID | Copyright | Expire | Name |
+----+-----------+--------+------+
|  |      1994 |   0000 | A    |
+----+-----------+--------+------+
row in set (0.00 sec)

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

mysql>
mysql>



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

MySQL TUTORIALS

 Navioo Insert Update Delete
» Insert