dousi3362 2015-03-24 21:02
浏览 94
已采纳

php INSERT INTO语法问题[关闭]

INSERT INTO Departments (DepartmentID, DepartmentName, Location, Phone, Chair)
VALUES (50, ‘Archival Information’, ‘B479’, 4321, ‘Robin’);

This works, but this does not:

INSERT INTO Departments (DepartmentID, DepartmentName, Location, Phone, Chair)
VALUES (50, ‘Archival Information’, ‘B479’, 4321, ‘Robin’),
(51, ‘Information Retrieval’, ‘B431’, 4322, ‘Sheela’),
(52, ‘Information Organization’, ‘B410’, 4323, ‘Craig’),
(53, ‘Information Policy’ ‘B204’, 4324, ‘Michael’),
(54, ‘Information Management’, ‘B219’, 4331, ‘Chris’),
(55, ‘Information Security’, ‘B225’, 4332, ‘Steve’),
(56, ‘Information Technology’, ‘B435’, 4333, ‘Arthur’),
(57, ‘Information Design’, ‘B300’, 4334, ‘Amy’),
(58, ‘Health Informatics’, ‘B428’, 4330, ‘Rav’),
(59, ‘Information Ethics’, ‘B356’, 4320, ‘Simon’);

What's the problem? I've checked syntax online and this is how I've noted the proper syntax is typed out.

  • 写回答

4条回答 默认 最新

  • dqo88037 2015-03-24 21:16
    关注

    Your single quotes are not correct except first one

    BTW your sql server is important only mssql 2008 or newer and mysql 4.1 or newer supports inserting more then one value with comma separating.

    The correct sql query :

    INSERT INTO Departments (DepartmentID, DepartmentName, Location, Phone, Chair)
    VALUES (50, 'Archival Information', 'B479', 4321, 'Robin'),
    (51, 'Information Retrieval', 'B431', 4322, 'Sheela'),
    (52, 'Information Organization', 'B410', 4323, 'Craig'),
    (53, 'Information Policy', 'B204', 4324, 'Michael'),
    (54, 'Information Management', 'B219', 4331, 'Chris'),
    (55, 'Information Security', 'B225', 4332, 'Steve'),
    (56, 'Information Technology', 'B435', 4333, 'Arthur'),
    (57, 'Information Design', 'B300', 4334, 'Amy'),
    (58, 'Health Informatics', 'B428', 4330, 'Rav'),
    (59, 'Information Ethics', 'B356', 4320, 'Simon');
    

    @exussum warn me about the mysql version so, I edited supported mysql version number 5.5 to 4.1 thank you.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵