1
我在mysql中有一個如下的結構化查詢。但它返回一個錯誤。基本上,我想從現有的表中獲得價值,並插入新表中。我嘗試了以下,但得到錯誤;sql語句中的insert語句返回多行
INSERT INTO `table1`(
`first`,`second`,`third`) VALUES(
(SELECT table2.timemodified FROM `xtable` AS table2,`ytable` AS table3
WHERE table3.id = table2.contextid),
(SELECT table4.id FROM `ztable` AS table4,`ytable` AS table3 WHERE table4.id = table3.instanceid),
(SELECT murs.id FROM `table5` AS murs,
`xtable` AS table2,
`wtable` AS table6,
`ytable` AS table3,
`vtable` AS table7
WHERE murs.id = table2.userid AND table6.id = table2.roleid AND table3.id = table2.contextid AND table7.instance = table3.instanceid AND table6.id =3)
);
我測試過,但錯誤是:#1242 - Subquery returns more than 1 row
。問題是我從insert
內部的select
查詢得到的單個記錄超過了單個記錄。我怎樣才能刪除這樣的錯誤。
你想插入多行ro只是一行。 – lordkain
是的,我想插入多行 – vijayrana
然後使用:插入表(值1,值2,值3)從表2中選擇x,y,z – lordkain