将行转换成mysql列

时间:2018-07-02 08:39:47

标签: mysql pivot group-concat pivotviewer

曾经希望将行(progress_check)旋转为列检查1,检查2等...不需要总和或总和,只是希望显示结果...任何人都可以帮忙。 这里是我的查询 这是我的查询,给出输出

SELECT
  `NGN_ClientInfo`.`ClientInfoID`   AS `ClientInfoID`,
  `NGN_ClientInfo`.`ClientInfoName` AS `ClientInfoName`,
  IFNULL(`NGN_LicenseInfo`.`License`,'') AS `LicenseInfo`,
  IFNULL(`NGN_LicenseInfo`.`LDKLicense`,'') AS `LDKLicenseInfo`,
  `NGN_ClientInfo`.`DBName`         AS `DBName`,
  SUBSTRING_INDEX(`NGN_ClientInfo`.`DBName`,'_',-(1)) AS `DBPostfix`,
  `NGN_ClientInfo`.`AdminDBIP`      AS `AdminDBIP`,
  `NGN_ClientInfo`.`DBPort`         AS `DBPort`,
  `NGN_ClientInfo`.`AdminURL`       AS `AdminURL`,
  `NGN_SBCProfile`.`SBCProfileID`   AS `SBCProfileID`,
  `NGN_SBCProfileLog`.`IPAddress`   AS `IPAddress`,
  `NGN_ServerInfo`.`IPAddress`      AS `ServerSocketAddress`,
  `NGN_ServerInfoLog`.`MaxCall`     AS `MaxCall`,
  `NGN_Version`.`VersionPrefix`     AS `VersionPrefix`
FROM ((((((`NGN_ClientInfo`
        LEFT JOIN `NGN_LicenseInfo`
          ON ((`NGN_ClientInfo`.`LicenseInfoID` = `NGN_LicenseInfo`.`LicenseInfoID`)))
       JOIN `NGN_SBCProfile`)
      JOIN `NGN_SBCProfileLog`)
     JOIN `NGN_ServerInfo`)
    JOIN `NGN_ServerInfoLog`)
   JOIN `NGN_Version`)
WHERE ((`NGN_SBCProfile`.`ClientInfoID` = `NGN_ClientInfo`.`ClientInfoID`)
       AND (`NGN_SBCProfile`.`SBCProfileLogID` = `NGN_SBCProfileLog`.`SBCProfileLogID`)
       AND (`NGN_SBCProfile`.`ServerInfoID` = `NGN_ServerInfo`.`ServerInfoID`)
       AND (`NGN_ServerInfo`.`ServerInfoLogID` = `NGN_ServerInfoLog`.`ServerInfoLogID`)
       AND (`NGN_ClientInfo`.`VersionID` = `NGN_Version`.`VersionID`)
       AND (`NGN_ClientInfo`.`IsActive` = '1')
       AND (`NGN_ClientInfo`.`IsDeleted` = '0')
       AND (`NGN_ServerInfoLog`.`IsActive` = '1')
       AND (`NGN_ServerInfoLog`.`IsDeleted` = '0')
       AND (`NGN_SBCProfileLog`.`IsActive` = '1')
       AND (`NGN_SBCProfileLog`.`IsDeleted` = '0')
       AND (`NGN_ServerInfo`.`ServerType` = '0'))

及其输出

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#

在这里,我想显示这样的输出

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

我们可以创建视图还是类似的视图? 我是mysql的新手,学习可以提供任何帮助

0 个答案:

没有答案