例如有两个表
a:|order|color|sizx|qty|
|is-01| red | s | 5 |
|is-01| red | m | 10|
|is-01| red | l | 15|
|is-01| blue| s | 5 |
|is-01| blue| m | 10|
|is-01| blue| l | 15|b:| po |order|color|sizx|qty|
|po-01|is-01| red | s | 5 |
|po-01|is-01| red | l | 15|
|po-01|is-01| blue| s | 5 |
|po-02|is-01| red | m | 10|
|po-02|is-01| blue| m | 10|
|po-02|is-01| blue| l | 15|
想要查询结果如下:
|order|color|qty| po |
|is-01| red | 30| po-01,po-02 |
|is-01| bule| 30| po-01,po-02 |请问该SQL如何写,MYSQL有字符函数可以实现|PO-01,PO-02|吗?
另外,我的MYSQL版本不支持多重查询
a:|order|color|sizx|qty|
|is-01| red | s | 5 |
|is-01| red | m | 10|
|is-01| red | l | 15|
|is-01| blue| s | 5 |
|is-01| blue| m | 10|
|is-01| blue| l | 15|b:| po |order|color|sizx|qty|
|po-01|is-01| red | s | 5 |
|po-01|is-01| red | l | 15|
|po-01|is-01| blue| s | 5 |
|po-02|is-01| red | m | 10|
|po-02|is-01| blue| m | 10|
|po-02|is-01| blue| l | 15|
想要查询结果如下:
|order|color|qty| po |
|is-01| red | 30| po-01,po-02 |
|is-01| bule| 30| po-01,po-02 |请问该SQL如何写,MYSQL有字符函数可以实现|PO-01,PO-02|吗?
另外,我的MYSQL版本不支持多重查询
¦is-01 ¦ red ¦ s ¦ 5 ¦
¦is-01 ¦ red ¦ m ¦ 10 ¦
¦is-01 ¦ red ¦ l ¦ 15 ¦
¦is-01 ¦ blue ¦ s ¦ 5 ¦
¦is-01 ¦ blue ¦ m ¦ 10 ¦
¦is-01 ¦ blue ¦ l ¦ 15 ¦ b: ¦ po ¦order ¦color ¦sizx ¦qty ¦
¦po-01¦is-01 ¦ red ¦ s ¦ 5 ¦
¦po-01¦is-01 ¦ red ¦ l ¦ 15 ¦
¦po-01¦is-01 ¦ blue ¦ s ¦ 5 ¦
¦po-02¦is-01 ¦ red ¦ m ¦ 10 ¦
¦po-02¦is-01 ¦ blue ¦ m ¦ 10 ¦
¦po-02¦is-01 ¦ blue ¦ l ¦ 15 ¦
想要查询结果如下:
¦order ¦color ¦qty ¦ po ¦
¦is-01 ¦ red ¦ 30 ¦ po-01,po-02 ¦
¦is-01 ¦ bule ¦ 30 ¦ po-01,po-02 ¦
from a left join b
on a.order=b.order and a.color=b.color
group by a.order,a.color
from a left join b
on a.order=b.order and a.color=b.color
group by a.order,a.color
但我使用的那个MYSQL版本是4.0,而group_concat要4.1才支持,
请问还有其他办法吗?无法升级MYSQL,因为数据库在别人的服务器上面