简体   繁体   中英

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:

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.

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. This are 4 queries. In PHP, you will have to call mysql_query four times.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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