2
我有一组类型的表。MySQL的选择Set分离
这个领域是一个彩色标签:
set('Red', 'Blue', 'Green')
每条记录可以有多种颜色,如:
红色和蓝色
现在,当我选择,我得到:
红,蓝,绿
是否有可能将其更改为:
蓝 - 绿 - 红
感谢
我有一组类型的表。MySQL的选择Set分离
这个领域是一个彩色标签:
set('Red', 'Blue', 'Green')
每条记录可以有多种颜色,如:
红色和蓝色
现在,当我选择,我得到:
红,蓝,绿
是否有可能将其更改为:
蓝 - 绿 - 红
感谢
尝试
select substr(concat(
if(color='Blue', ' - Blue', ''),
if(color='Green',' - Green', ''),
if(color='Red',' - Red','')
), 3) as customfield
所以如果我有更多的颜色,我将不得不每次更改我的查询? – 2012-02-21 00:54:16
是的,否则你必须创建一个storedprocedure – silly 2012-02-21 04:54:04