0

この MySQL クエリの何が問題で、どうすれば解決できますか?

SELECT f.uniqueidentifier FROM db.engine4_passport_userforms uf
INNER JOIN db.engine4_passport_forms f ON uf.form_id = f.form_id
WHERE uf.user_id = 10
INSERT INTO db.engine4_passport_registrationchildren (parentid, `First Name`, Surname, Relationship) VALUES ( f.uniqueidentifier, '', '', '')
INSERT INTO db.engine4_passport_registrationcontactdetails (Address, Telephone, UID, Postcode) VALUES ('3 street', '',  f.uniqueidentifier, 'aaaaaa')
INSERT INTO db.engine4_passport_registrationcontactprefs (parentid, prefs) VALUES ( f.uniqueidentifier, 'Post Email ')
INSERT INTO db.engine4_passport_registrationfoundus (parentid, medium, `reason for joining`) VALUES ( f.uniqueidentifier, '', '')
INSERT INTO db.engine4_passport_registrationhousehold (parentid, `chief earner occupation`, `number of people`, `number of children`) VALUES ( f.uniqueidentifier, 'build', '1', '0')
INSERT INTO db.engine4_passport_registrationinterests (parentid, interest) VALUES ( f.uniqueidentifier, '')
INSERT INTO db.engine4_passport_registrationpersonaldetails (parentid, ethnicity) VALUES ( f.uniqueidentifier, 'White')
INSERT INTO db.engine4_passport_registrationqanda VALUES ( f.uniqueidentifier, '4', '1', '1', '1', '3', '3', '5', '5', '3', '4', '5', '4')
INSERT INTO db.engine4_passport_registrationteam (parentid, team?, `no of team members`, relationship) VALUES ( f.uniqueidentifier, 'No', '', '')
INSERT INTO db.engine4_passport_registrationuserlink (userid, regformUID) VALUES ('10',  f.uniqueidentifier);

これが私が得ているエラーです:

Script line: 1  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 db.engine4_passport_registrationchildren (parentid, `Fir' at line 2
4

2 に答える 2

2

これらは複数のクエリであり、1 つだけではありません。;それらを分離するために間に追加します。

select ....
inner join ...
where ...;

insert into ...;
values ...

...

編集

前の選択の値を使用する場合は、変数を使用できます。例:

SELECT @var := f.uniqueidentifier 
FROM db.engine4_passport_userforms uf
INNER JOIN db.engine4_passport_forms f ON uf.form_id = f.form_id
WHERE uf.user_id = 10;

INSERT INTO db.engine4_passport_registrationchildren (parentid, `First Name`, Surname, Relationship) 
VALUES (@var, '', '', '');
于 2012-10-05T15:12:18.840 に答える
0

複数のクエリは、 simicolon で終了する必要があります;。単一のクエリはセミコロンなしで問題ありませんが、複数のクエリを mysql サーバーに送信する場合は、次のように終了する必要があります。;

于 2012-10-05T15:12:38.030 に答える