MySQL查询以行显示为列 [英] MySql Query to show rows as columns
本文介绍了MySQL查询以行显示为列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有两个下面的表格.
帐户-表1
Hi,
I have two tables like Below..
Accounts - Table1
AccID AccType
1 A
2 B
3 C
事务-Table2
Transactions - Table2
TrID TrTo_AccID TrAmount
100 1 1000
100 2 2000
101 1 3000
101 2 4000
101 3 5000
现在我需要获得如下输出.
Now i need to get output like below..
TrID A_Tr B_Tr C_Tr
100 1000 2000 null
101 3000 4000 5000
如何编写Mysql查询以获取此输出..请帮助..
在此先感谢...
How can i write Mysql query to get this output.. Please help..
Thanks in advance...
推荐答案
检查这些
MySQL/数据透视表 [使用MySQL的交叉制表(数据透视表) [ ^ ]
MySQL中的数据透视表 [
Check these
MySQL/Pivot table[^]
Cross-Tabulation (Pivot Tables) with MySQL[^]
Pivot tables in MySQL[^]
这篇关于MySQL查询以行显示为列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文