本文介绍了转置查询输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好, 在almsot 2 - 3年后回到Bytes感觉真好..反正这里是我的问题。我想转置我的查询输出。 这里有详细信息.. ***表 GDCA gdcid,gdcid,gdaid,年龄 GDA gdaid ,名称 ***查询 SELECT gda.id,年龄 来自 gdca JOIN gda ON(gda.id = gdca.gdaid) WHERE gdca。 gdcid IN(3573,184) 订购gdca.id ***输出 " ID" 年龄 " 1" 0 " 1" 11 " 2" 0 " 2" 30 " 3" 0 " 3" 1 " 4" " 0" " 4" 1 " 5" 0 " 5" 1 ***我想要它类似 1 2 3 4 5 0 0 0 0 0 11 30 0 0 0 我尝试使用IF()子句甚至是CONCAT然后再使用SUBSTRING_INDEX,但是没有得到所需的输出。 任何指针都表示赞赏。 谢谢和问候, RP Hi All, It feels so good to be back on Bytes after almsot 2-3 years.. anyways here is my quesion. I would like to transpose my query output. here are the details.. *** Tables GDCAgdcid,gdcid,gdaid,age GDA gdaid,name *** Queries SELECT gda.id,ageFROM gdca JOIN gda ON (gda.id = gdca.gdaid)WHERE gdca.gdcid IN(3573,184)ORDER BY gdca.id *** Output "id""age""1""0""1""11""2""0""2""30""3""0""3""1""4""0""4""1""5""0""5""1" *** I want it something like 1 2 3 4 50 0 0 0 011 30 0 0 0 I tried using IF() clause or even CONCAT and then SUBSTRING_INDEX, however not getting the required output. Any pointer is appreciated. Thanks and Regards,RP推荐答案 这篇关于转置查询输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-23 02:35