MySQL query to insert row with date?

MySQLMySQLi Database

Let us first create a table −

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 some records in the table using insert command −

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)

Display all records from the table using select statement −

mysql> select *from DemoTable;

This will produce the following output −

+------------+--------------+-------------+
| 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)
raja
Published on 03-Sep-2019 17:12:12
Advertisements