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

报告相同问题?