![](/img/trans.png)
[英]How to select only rows from a table one clumns value is more than b table count value in MySQL
[英]Select Multi rows from table B according to array value in table A
which stores id values of table A rows as array, how can I output IN ONE SELECT STATEMENT the title of each id in table B, like that: 我有两个表(A,B),B表具有一列 ,该列将表A行的ID值存储为数组,如何在一个选择语句中输出表B中每个ID的标题,如下所示:
Table B :
id title
1 Apple
2 Orange
Table A :
id Fruit
1 1,2
结果:
A.id A.Fruit
1 Apple,Orange
SELECT a.id, GROUP_CONCAT(b.title)
FROm tableA a
LEFT JOIN tableB b
ON FIND_IN_SET(b.id , a.Fruit)
GROUP BY a.id
SELECT Fruit FROM Table B WHERE Fruit IN (SELECT Fruit FROM Table A);
我不知道这是否对您有用,但希望对您有所帮助。 您可能需要使用Subqueries 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.