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条)

报告相同问题?

悬赏问题

  • ¥80 构建降雨和积水的预测模型
  • ¥15 #Qt Transform setTransform()在鼠标拖动移动视角是一致在原地不动,无法变换视角(细微观察似乎视图有在原地抖动),无法变换视角(细微观察似乎视图有在原地抖动)
  • ¥50 如何利用无人机拍摄的数码照片测量鸟卵的长短径
  • ¥100 github贡献者给与奖励
  • ¥15 使用DS18B20+ESP8266获取温度数据返回-127.00
  • ¥15 odbc代码新增sqlserver数据源
  • ¥15 求一个USB指纹识别的驱动
  • ¥15 wps中工作表与工作表之间怎么汇总信息?
  • ¥50 请教Windows server 2012 R2的DCOM配置问题
  • ¥15 adasis v3中LaneConnectivity