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

解决方案,当然,两者的含义也不一样,需要自行判断。https://www.cndba.cn/hbhe0316/article/22648https://www.cndba.cn/hbhe0316/article/22648

https://www.cndba.cn/hbhe0316/article/22648
https://www.cndba.cn/hbhe0316/article/22648 https://www.cndba.cn/hbhe0316/article/22648 https://www.cndba.cn/hbhe0316/article/22648 https://www.cndba.cn/hbhe0316/article/22648
https://www.cndba.cn/hbhe0316/article/22648
https://www.cndba.cn/hbhe0316/article/22648
https://www.cndba.cn/hbhe0316/article/22648
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

你可能感兴趣的:(python,mysql,java,php,https)