我的表foo1包含UserID,TimeStamp列; foo2,列为userID,Level&表foo3,其中包含userID,Timestamp。
我想从表foo2中存在UserID的foo3中插入foo1的所有行。
我收到ERROR 1242:子查询返回的行数超过1行
INSERT into foo1 (UserID,TimeStamp)
SELECT
(SELECT UserID from foo2 as UserID),
(SELECT foo3.TimeStamp
from foo3
inner join foo2
ON foo3.UserID=foo2.UserID) as TimeStamp
答案 0 :(得分:5)
如果你想从表foo2中存在UserID的foo3中插入foo1的所有行,那么你应该经历这个:
INSERT into foo1 (UserID,TimeStamp) SELECT foo3.UserID,foo3.TimeStamp from foo3 inner join foo2 ON foo3.UserID=foo2.UserID