基于列值的动态列别名 [英] Dynamic column alias based on column value

查看:89
本文介绍了基于列值的动态列别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据mysql中的列值来命名列别名。这是可能的吗?

I want to name the column alias based on the column value in mysql. Is that possible?

这样的东西

select  
  case when answer_type = 'RB' then 
     answer_type as 'radio'
 else 
     answer_type as 'evrything_else'
 end case
from  XTable 


推荐答案

不,这在纯SQL中是不可能的。您可能必须查询数据,然后在执行查询的任何应用程序中进行处理。

No, that's not possible in pure SQL. You'll probably have to query the data out and then process it in whatever application is executing the query.

这篇关于基于列值的动态列别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆