Tạo bảng:
mysql> create table DemoTable -> ( -> Value int -> ); Query OK, 0 rows affected (0.80 sec)
Chèn dữ liệu:
mysql> insert into DemoTable values(10); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable values(20); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(100); Query OK, 1 row affected (0.14 sec)
Hiển thị dữ liệu:
mysql> select *from DemoTable;
Kết quả
+-------+ | Value | +-------+ | 10 | | 20 | | 100 | +-------+ 3 rows in set (0.00 sec)
Truy vấn nhân -1 và ép kiểu sang SIGNED:
mysql> select cast(Value*-1 as signed) from DemoTable;
Kết quả
+--------------------------+ | cast(Value*-1 as signed) | +--------------------------+ | -10 | | -20 | | -100 | +--------------------------+ 3 rows in set (0.00 sec)