我的purchaseproduct表
+------------+------------+
| productids | quantities |
+------------+------------+
| 1,3,4,5 | 1,1,1,1 |
| 2,3,4,5 | 1,1,1,1 |
+------------+------------+我的产品表
productsid | productsname |
+------------+-----------------------------+
| 1 | Phone |
| 2 | Laptop |
| 3 | Charger |
| 4 | Earphone |
| 5 | Camera |我想在purchaseproduct表中获取基于productids的产品名称
如下所示,输出是必需的
Phone,Charger,Earphone,Camera (In row one)
Laptop,Charger,Earphone,Camera (In row two)我尝试了下面的语句和其他许多语句
select group_concat(p.productsname) from purchaseproducts as pp join products as p on find_in_set(p.productsid,pp.productids);但是我得到的输出是
Phone,Charger,Earphone,Camera,Laptop,Charger,Earphone,Camera (All in one row)如何才能获得所需的输出?
https://stackoverflow.com/questions/38348545
复制相似问题