Presentation is loading. Please wait.

Presentation is loading. Please wait.

MySQL tutorial using data

Similar presentations


Presentation on theme: "MySQL tutorial using data"— Presentation transcript:

1 MySQL tutorial using 2017 311 data
Create a table Load data into a table Perform basic queries Export the data

2 Syntax for creating our table
create table if not exists SC_2017_test (id_num mediumInt not null auto_increment primary key,creation_date datetime, ward varchar(50), call_description varchar(35), call_type varchar(50), maintenance_yard varchar(75), priority_name varchar(120)); NOTE: MAKE SURE EACH STATEMENT IN YOUR CREATE TABLE QUERY IS SEPARATED BY A COMMA

3 Syntax for loading a file
LOAD DATA INFILE ‘complete path to text file’ INTO TABLE TableName FIELDS TERMINATED BY ‘,’ OPTIONALLY ENCLOSED BY ‘”’ LINES TERMINATED BY ‘\n’ IGNORE n LINES For reference, read pages 85 to 93 in The Data Journalist

4 Syntax for importing Jan 2017 file
load data local infile "c:\\01-sr-2017.csv“ into Table SC_2017_test Fields terminated by ',' enclosed by '"' Lines terminated by '\n' Ignore 1 Lines (maintenance_yard, call_type, call_description, priority_name, ward) set creation_date = makedate('2017', dayofyear(' '));

5 First few queries Select count(*) from sc_2017_test;
Select * from sc_2017_test limit 100; Select * from from sc_2017_test limit 100 where call_type = ‘Animals’;


Download ppt "MySQL tutorial using data"

Similar presentations


Ads by Google