这是我的代码:
$query3="LOAD DATA INFILE
'C:/xampp/htdocs/schoolonweb/trainee/views/sliptest/sliptestuploads/$filename'
INTO TABLE $sliptesttable
(SchoolId,ClassId,SectionId,SubjectId,NewSubjectId,
SlipTestId,StudentId,Mark)
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' ";
我收到以下错误:
您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在第1行'FIELDS TERMINATED BY','LINES TERMINATED BY''附近使用正确的语法
有人可以找到错误的位置吗?
答案 0 :(得分:0)
语法不正确。试试这个 -
LOAD DATA INFILE
'C:/xampp/htdocs/schoolonweb/trainee/views/sliptest/sliptestuploads/$filename'
INTO TABLE $sliptesttable
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
(SchoolId,ClassId,SectionId,SubjectId,NewSubjectId, SlipTestId,StudentId,Mark)
答案 1 :(得分:0)
我认为字段声明必须在声明终止的字段之后:
$query3="LOAD DATA INFILE
'C:/xampp/htdocs/schoolonweb/trainee/views/sliptest/sliptestuploads/$filename'
INTO TABLE $sliptesttable
FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'
(SchoolId,ClassId,SectionId,SubjectId,NewSubjectId,
SlipTestId,StudentId,Mark) ";
MySQL中的以这种方式工作documentation