SELECT * FROM ENQUIRY_GOODS_ATTR_DETAIL a WHERE a.GOODS_DETAIL_ID = 2;
将上面的查询数据转换成一行数据,用分号隔开。
SELECT GROUP_CONCAT( CONCAT(a.ATTR_NAME,a.ATTR_VALUE) ORDER BY a.ORDER_NUM ASC SEPARATOR ';') AS content
FROM ENQUIRY_GOODS_ATTR_DETAIL a WHERE a.GOODS_DETAIL_ID = 2;
如果有重复的数据可以使用DISTINCT去重复。
SELECT GROUP_CONCAT( DISTINCT CONCAT(a.ATTR_NAME,a.ATTR_VALUE) ORDER BY a.ORDER_NUM ASC SEPARATOR ';') AS content
FROM ENQUIRY_GOODS_ATTR_DETAIL a WHERE a.GOODS_DETAIL_ID = 2;
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。