mysql 行转列

SELECT
REPLACE(GROUP_CONCAT(IF(ItemID=1101,ItemValue,"")),',',"") AS 'Item1101',
REPLACE(GROUP_CONCAT(IF(ItemID=1102,ItemValue,"")),',',"") AS 'Item1102',
REPLACE(GROUP_CONCAT(IF(ItemID=1103,ItemValue,"")),',',"") AS 'Item1103',
REPLACE(GROUP_CONCAT(IF(ItemID=1104,ItemValue,"")),',',"") AS 'Item1104',
REPLACE(GROUP_CONCAT(IF(ItemID=1105,ItemValue,"")),',',"") AS 'Item1105',
REPLACE(GROUP_CONCAT(IF(ItemID=1106,ItemValue,"")),',',"") AS 'Item1106',
REPLACE(GROUP_CONCAT(IF(ItemID=1107,ItemValue,"")),',',"") AS 'Item1107',
REPLACE(GROUP_CONCAT(IF(ItemID=1108,ItemValue,"")),',',"") AS 'Item1108'
FROM stroke_datainfo GROUP BY rid

你可能感兴趣的:(mysql)