Uploading CSV file using MySql query

The query to upload a CSV file using MySQL query from local computer to database, so that the records should be inserted automatically from the CSV file.
The query is :


LOAD DATA LOCAL INFILE 'C:\\wamp\\apps\\phpmyadmin3.5.1\\db_learning.csv'
INTO TABLE tbl_master_quiz_question
FIELDS TERMINATED BY '%'
LINES TERMINATED BY '\n'


The path in the query should be given by using a double backslash. The 'FIELDS TERMINATED BY' is used to acknowledge the termination of values according to fields in the database. And 'LINES TERMINATED BY' is used to acknowledge where the row ends.


the db_learning.csv file is as follows :


10% 0% Enter questions here, it will grow automatically.% sadf% asdf% fds% asdf% fdas% 10
11% 0% Which is not the access specifier?% public% friend% protected% int% int% 10
15% 0% Enter questions here, it will grow automatically.% qwer% qwer% qwer% wer% er% 10
16% 0% Enter questions here, it will grow automatically.% asdf% asdf% adsf% asdf% asdf% 10
18% 1% What will be output of the following program?#include<stdio.h>int main(){ float a=0.7;d if(a<0.7){ printf("C"); } else{ printf("C++"); } return 0;}% C% C++% Syntax Error% Compilation Error% C% 10
19% 0% Enter questions here, it will grow automatically.% 1% 2% 3% 4% 4% 1
21% 1% Enter questions here, it'll grow automatically.% 1% 12% 123% 1234% 1% 1

Comments