查询字段中所有的值,不取重复

正文开始

SELECT group_concat(distinct k_color) as color,group_concat(distinct k_guige) as guige,group_concat(distinct k_qiujing) <br /><p>as guangdu FROM `spu_sku_yinxingyanjing` WHERE k_spu_id=2710 AND k_online=1</p><p><br /></p><p>取多个不重复的字段,并且组合输出:</p><p>SELECT <br />group_concat(distinct k_qulv) as qulv,<br />group_concat(distinct k_moceng) as moceng,<br />group_concat(distinct CONCAT(k_lr,'_',k_qiujing)) as qiujing,<br />group_concat(distinct CONCAT(k_lr,'_',k_zhujing)) ,<br />group_concat(distinct CONCAT(k_lr,'_',k_xiajiaguang)) as xiajiaguang,<br />group_concat(distinct k_tongdao) as tongdao <br />FROM `spu_sku_jingpian_duojiaodian` WHERE  k_spu_id=2877 AND k_online=1 and k_qulv='6'<br /></p><p><br /></p><p>注意事项: group_concat有字数限制 要注意改大 mysql配置 my.ini中加上 group_concat_max_len = 200000<br /></p><p><br /></p>

正文结束

Mysql Innodb 引擎优化 参数 MySQL查询不使用索引汇总