SQL语句:type类型1、2、3、4用具体的内容来显示

例题:MySQL数据库字段:`type` int(1) DEFAULT '0' COMMENT '类别,5:第三方,1:政府,2:高校,3:媒体,4:同行,'


用SQL语句表示case type when 1 then '政府' when 2 then '高校' when 3 then '媒体' when 4 then '同行' when 5 then '第三方' end


完整的SQL实例:

SELECT b.name as 所属组织,a.resource as 单位,

(case a.type when 1 then '政府' when 2 then '高校' when 3 then '媒体' when 4 then '同行' when 5 then '第三方'end) as 合作主题,

a.contact as 姓名,a.job as 职务,a.contact_mobile as 联系电话,

a.track_count as 跟踪次数 FROM cx_external_resources a,cx_role b WHERE a.incubator_id = b.id

ORDER BY a.update_time DESC

你可能感兴趣的:(SQL语句:type类型1、2、3、4用具体的内容来显示)