插入带有日期行的 MySQL 查询?
我们首先创建一个表 −
mysql> create table DemoTable( EmployeeId int NOT NULL AUTO_INCREMENT PRIMARY KEY, EmployeeName varchar(100), JoiningDate date ); Query OK, 0 rows affected (0.48 sec)
使用 insert 命令在表中插入一些记录 −
mysql> insert into DemoTable(EmployeeName,JoiningDate) values('Chris','2019-01-21'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(EmployeeName,JoiningDate) values('Robert','2016-12-01'); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(EmployeeName,JoiningDate) values('Mike','2015-03-12'); Query OK, 1 row affected (0.12 sec)
使用 select 语句显示表中的所有记录 −
mysql> select *from DemoTable;
这将生成以下输出 −
+------------+--------------+-------------+ | EmployeeId | EmployeeName | JoiningDate | +------------+--------------+-------------+ | 1 | Chris | 2019-01-21 | | 2 | Robert | 2016-12-01 | | 3 | Mike | 2015-03-12 | +------------+--------------+-------------+ 3 rows in set (0.00 sec)
广告