mysql - sql subquery return more than 1 row
伊谢尔伦
伊谢尔伦 2017-04-17 15:29:52
0
2
689
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伐。

모든 응답(2)
黄舟

where xxx = yyy, 오른쪽은 여러 값이 아닌 단일 값이어야 하며 첫 번째 명령문에서는

으아아아

은 여러 값을 감지하므로 Error Code: 1242. Subquery returns more than 1 row 오류가 보고됩니다

의 해결책은 where xxx = yyywhere xxx in(yyy) 또는 where xxx = any yyy으로 바꾸는 것입니다. 이 두 표현은 동일한 의미를 갖지만 where xxx > any yyy

과 같이 다른 방식으로 비교할 수도 있습니다.
左手右手慢动作

any는 꽤 in()입니다

최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿