While I focus on front-end development, writing a bit of back-end in Node is great. So you have to learn SQL statements. This series is about documenting your learning experience.

The first step is to create the database

//Creating a databasecreate database egg_house;

//Use egg_house;Copy the code

Create table

create table`house`(
    `id` int not null auto_increment,
    `name` varchar(50) default null comment 'Name of Premises'.`info` varchar(150) default null comment 'Housing Information'.`addres` varchar(200) default null comment 'House Address'.`price` int default null comment 'House price'.`publishTime` timestamp default null comment 'Release time'.`cityCode` varchar(10) not null comment 'City code'.`showCount` int(5) not null default 0 comment 'Show times'.`startTime` timestamp default null comment 'Start Time for hire'.`endTime` timestamp default null comment 'End of Hire time',
    primary key(`id`)
) engine = InnoDB auto_increment = 1 default charset = utf8 comment = 'House List';
Copy the code

Name Type Default Value Remarks. It also has to set an increment id as the primary key, select the engine, usually InnoDB.

Insert data

INSERT INTO `house` VALUES 
(1.'Dongcheng B&B'.'East Side near MTR'.'Dongcheng District'.200.'the 2020-08-10 13:37:57'.'10001'.1.'the 2020-08-10 13:37:57'.'the 2020-10-20 13:37:57'),
(2.'West City B&B'.'West End near MTR'.'West Town'.100.'the 2020-08-10 13:38:23'.'10001'.1.'the 2020-08-10 13:37:57'.'the 2020-11-10 13:37:57'),
(3.'New District Home Stay'.'Superior location of Homestay in New District'.'New town'.150.'the 2020-08-10 13:38:23'.'10001'.0.'the 2020-08-10 13:37:57'.'the 2020-12-10 13:37:57'),
(4.'Old Town Stay'.'Beautiful old town'.'Old Town'.100.'the 2020-08-10 13:38:23'.'10001'.0.'the 2020-08-10 13:37:57'.'the 2020-12-10 13:37:57'),
(5.Xiyuan B&B.'Xiyuan beautiful Scenery'.'West Town'.100.'the 2020-08-10 13:38:23'.'10001'.0.'the 2020-08-10 13:37:57'.'the 2020-11-10 13:37:57');
Copy the code

To correspond to the order of the set tables, you can write more than one at a time in visual software such as MySQL Workbench.

Record the record!