0
点赞
收藏
分享

微信扫一扫

Mysql ERROR 1242 (21000): Subquery returns more than 1 row


mysql> select count(*) from t1 where t1.id = (select t2.id from t2);
ERROR 1242 (21000): Subquery returns more than 1 row

解决方案,当然,两者的含义也不一样,需要自行判断。

mysql> select count(*) from t1 where t1.id = any(select t2.id from t2);
+----------+
| count(*) |
+----------+
| 959368 |
+----------+
1 row in set (2.12 sec)

mysql> select count(*) from t1 where t1.id = (select t2.id from t2 limit 1);
+----------+
| count(*) |
+----------+
| 2 |
+----------+
1 row in set (0.01 sec)

版权声明:本文为博主原创文章,未经博主允许不得转载。

MYSQL

举报

相关推荐

0 条评论