Ram*_*man 2 insert-into mysql-error-1242
我有表foo1的列UserID,TimeStamp; foo2,列为userID,Level&table为foo3,列为userID,Timestamp.
我想从表foo2中存在UserID的foo3中插入foo1的所有行.
我收到错误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
Run Code Online (Sandbox Code Playgroud)
小智 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