mysqlpivotgroup-concatpivotviewer

convert row into column mysql NO sum or Total or value


Been looking to pivot rows (progress_check) into columns check 1, check 2 etc... No sum or totals required, just to display the results hopefully... Can anyone help. HERE Is My query here is my query that giving output

SELECT  * FROM View_Client

ClientInfoID    ClientInfoName  DBName  DBPostfix   AdminDBIP   DBPort  AdminURL    SBCProfileID    IPAddress   ServerSocketAddress MaxCall VersionPrefix
3   Ankit   NGN_AdminPortal_V3C1_02 2   192.168.90.83   3306    http://192.168.90.83:9050   80  192.168.90.93   192.168.90.93   65535   34#
4   CNR_Client  NGN_AdminPortal_V3A_09  9   192.168.90.83   3306    http://192.168.60.113:6072  81  192.168.60.113  192.168.60.113  1000    30#
5   jayant  NGN_AdminPortal_V3C1_01 1   192.168.90.83   3306    http://192.168.90.83:9060   82  192.168.90.94   192.168.90.97   100 34#

AND i want to convert this out put into this form.

3   Ankit
3   NGN_AdminPortal_V3C1_02
3   2
3   192.168.90.83
3   3306
3   http://192.168.90.83:9050
3   80
3   192.168.90.93
3   192.168.90.93
3   65535
3   34#
4   CNR_Client
4   NGN_AdminPortal_V3A_09
4   9

where first filed is ClientInfoID and other fields are associate with it. i am new in mysql so can anyone help.


Solution

  • How about...

    SELECT ClientInfoID, ClientInfoName AS CommonColumn FROM View_Client UNION ALL
    SELECT ClientInfoID, DBName FROM View_Client UNION ALL
    SELECT ClientInfoID, DBPostfix FROM View_Client UNION ALL
    ...
    SELECT ClientInfoID, VersionPrefix FROM View_Client;
    

    (you can debate on UNION ALL vs UNION... another topic.. one would keep duplicate another would not; respectively.)