2

次のクエリを実行しようとしています:

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;

これにより、次の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

同時に、phpMyAdminはこのクエリを実行することができます。

誰かが考えられる理由を指摘してもらえますか?

4

2 に答える 2

1

あなたは試すことができます:

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' ); 

これにより、1つのステートメントに2つの挿入ができます。

于 2012-12-13T20:09:43.417 に答える
0

これは「a」クエリではありません。これは4つのクエリです。PHPでは、mysql_queryを4回呼び出す必要があります。

于 2012-12-13T20:12:16.453 に答える