为什么使用另一张表的筛选结果,放到where id in ()里面,结果不对?
比如现在固定筛选,5514,5515这两个id是可以的。
mysql> select id from terminal where id in (5514,5515);
+------+
| id |
+------+
| 5514 |
| 5515 |
+------+
2 rows in set (0.08 sec)
另一张表的某个json里面有个字段,记录的这个id表,也没问题,能查出来5514,5515
mysql> select pgrpdevlist ->> '$.devicelist' from playproject where id = 13;
+--------------------------------+
| pgrpdevlist ->> '$.devicelist' |
+--------------------------------+
| 5514,5515 |
+--------------------------------+
1 row in set (0.06 sec)
但是两个结合起来就有问题了,只能读出来一个。
mysql> select id from terminal where id in (select pgrpdevlist ->> '$.devicelist' from playproject where id = 13);
+------+
| id |
+------+
| 5514 |
+------+
1 row in set (0.09 sec)