mysql 批量多表 insert 语句在 php mysqli->query() 执行时语法错误 5
类似以下的语句,一次性对三张自增id的表批量插入数据得到错误信息Erreurdesyntaxeprèsde'INSERTINTOteachers(name,sex)'àl...
类似以下的语句,一次性对三张自增id 的表 批量插入数据
得到错误信息
Erreur de syntaxe près de 'INSERT INTO teachers(name,sex)' à la ligne 2
以下是在 php mysqli -> query() 执行的sql
set @s=0,@t=0;
INSERT INTO teachers(name,sex) VALUES ('王老师','男');
set @t=@@IDENTITY;
INSERT INTO students(name,classes) VALUES (''张三,'(1)班');
set @s=@@IDENTITY;
INSERT INTO courses_student(name,student_id,teacher_id) VALUES ('语文',@s,@t);
INSERT INTO courses_student(name,student_id,teacher_id) VALUES ('数学',@s,@t);
INSERT INTO students(name,classes) VALUES (''李四,'(1)班');
set @s=@@IDENTITY;
INSERT INTO courses_student(name,student_id,teacher_id) VALUES ('语文',@s,@t);
INSERT INTO courses_student(name,student_id,teacher_id) VALUES ('数学',@s,@t);
上文中
INSERT INTO students(name,classes) VALUES (''张三,'(1)班');
INSERT INTO students(name,classes) VALUES (''李四,'(1)班');
改成
INSERT INTO students(name,classes) VALUES ('张三','(1)班');
INSERT INTO students(name,classes) VALUES ('李四','(1)班'); 展开
得到错误信息
Erreur de syntaxe près de 'INSERT INTO teachers(name,sex)' à la ligne 2
以下是在 php mysqli -> query() 执行的sql
set @s=0,@t=0;
INSERT INTO teachers(name,sex) VALUES ('王老师','男');
set @t=@@IDENTITY;
INSERT INTO students(name,classes) VALUES (''张三,'(1)班');
set @s=@@IDENTITY;
INSERT INTO courses_student(name,student_id,teacher_id) VALUES ('语文',@s,@t);
INSERT INTO courses_student(name,student_id,teacher_id) VALUES ('数学',@s,@t);
INSERT INTO students(name,classes) VALUES (''李四,'(1)班');
set @s=@@IDENTITY;
INSERT INTO courses_student(name,student_id,teacher_id) VALUES ('语文',@s,@t);
INSERT INTO courses_student(name,student_id,teacher_id) VALUES ('数学',@s,@t);
上文中
INSERT INTO students(name,classes) VALUES (''张三,'(1)班');
INSERT INTO students(name,classes) VALUES (''李四,'(1)班');
改成
INSERT INTO students(name,classes) VALUES ('张三','(1)班');
INSERT INTO students(name,classes) VALUES ('李四','(1)班'); 展开
1个回答
2015-06-01
展开全部
INSERT INTO students(name,classes) VALUES (''张三,'(1)班');
INSERT INTO students(name,classes) VALUES (''李四,'(1)班'); 引号大乱哗大错了滚芦档
INSERT INTO students(name,classes) VALUES (''李四,'(1)班'); 引号大乱哗大错了滚芦档
追问
很感谢你的回答,
去吧引号改了还是不行
哪些语句的cmd中能执行,但在mysqli -> query 中就是不行
追答
报什么错误!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询