简体   繁体   English

phpMyAdmin执行时MySQL查询无法执行

[英]MySQL query fails to execute while phpMyAdmin executes

I am trying to execute next query: 我正在尝试执行下一个查询:

BEGIN;
INSERT INTO `jobs` ( `client` , `client_name` , `type` , `workers` , `date` , `hours` , `comments` , `project` ) VALUES ( '1' , 'one' , '1' , '1,2,5' , '2012-12-13' , '1234f' , '' , '0' ); 
INSERT INTO `jobs` ( `client` , `client_name` , `type` , `workers` , `date` , `hours` , `comments` , `project` ) VALUES ( '5' , 'two' , '3' , '1,2,5' , '2012-12-13' , '12' , '' , '0' ); 
COMMIT;

This returns the next MySQL error: 这将返回下一个MySQL错误:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INSERT INTO `jobs` ( `client` , `client_name` , `type` , `workers` , `date` , `h' at line 1

At the same time, phpMyAdmin manages to execute this query. 同时,phpMyAdmin设法执行该查询。

Could someone please point on a possible reason? 有人可以指出可能的原因吗?

You could try: 您可以尝试:

INSERT INTO `jobs` ( `client` , `client_name` , `type` , `workers` , `date` , `hours` , `comments` , `project` ) 
    VALUES ( '1' , 'one' , '1' , '1,2,5' , '2012-12-13' , '1234f' , '' , '0' )
    ,( '5' , 'two' , '3' , '1,2,5' , '2012-12-13' , '12' , '' , '0' ); 

That will give you two inserts in one statement. 这将在一条语句中为您提供两个插入。

This is not 'a' query. 这不是“ a”查询。 This are 4 queries. 这是4个查询。 In PHP, you will have to call mysql_query four times. 在PHP中,您将不得不调用mysql_query四次。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM