mysql - sql subquery return more than 1 row
伊谢尔伦
伊谢尔伦 2017-04-17 15:29:52
0
2
667
update orders_father set ostatus=5,ofintimesys=now() where oid =
(select oid from
(SELECT oid FROM orders_father where TIMESTAMPDIFF(HOUR,odlvtime,now())>parameter and ostatus=4)
as tempTable)
;

这是代码1。

    update orders_father set ostatus=5,ofintimesys=now() where oid =any
(select oid from
(SELECT oid FROM orders_father where TIMESTAMPDIFF(HOUR,odlvtime,now())>parameter and ostatus=4)
as tempTable)
;

这是代码2,在oid=后面增加了any

我的疑问是,为何代码1会出现Error Code: 1242. Subquery returns more than 1 row
这种错误,而代码2不会? 谢谢各位大神

背景:我是在存储过程中使用的...

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
黄舟

where xxx = yyy, the right side must be a single value, not multiple values, and

in your first statement
(SELECT oid FROM orders_father where TIMESTAMPDIFF(HOUR,odlvtime,now())>parameter and ostatus=4)
as tempTable)

will find multiple values, so Error Code: 1242. Subquery returns more than 1 row error

is reported The solution to

is to change where xxx = yyy into where xxx in(yyy) or where xxx = any yyy. These two expressions have the same meaning, but any can also be compared in other ways, such as where xxx > any yyy

左手右手慢动作

any is quite in()

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template