例如有两个表
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版本不支持多重查询
解决方案 »
- 如何把 .sql 文件导入到 MySql 数据库中啊?请高手们指导一下
- mysql触发器,过程,函数调用
- 急。。。如何实现这个功能呢?
- 年月+日(日在列上) 化列为行
- MySQL插入数据库的瞬间时区改变
- 解决mysql4.0.17导出乱码问题
- 有关转资料的简单问题
- 如何将ACCESS/MSSQL 的表结构 导如 MYSQL???
- 一个线程执行mysql_store_result得到的MYSQL_RES,可以传递给另一个线程处理,并让其用free_result释放么?
- MYSQL 主从复制,但是用C++ API的操作都不同步,有遇到这样的吗?
- mysql 管理工具 sqlyog
- 请问 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,因为数据库在别人的服务器上面