问题一:
select id,
       case type when '1' then '一类' 
else when '2' then '甲等' end type,
name
from tab

解决方案 »

  1.   

    表 t
    id ls(varchar)
    ----------------------------
    1 1,3
    2 2,4
    什么意思?1 1,3表示什么?
      

  2.   

    表 tt 没有对应的表来保存1,2等对应的type吗?难道要写死?
      

  3.   

    没有 存 对应的 type ~!
      

  4.   


    id = int
    ls = varchar
      

  5.   


    -- 问题2: 
    select id, 
    (select id from t where charindex(','+ltrim(d.id)+',', ','+ls+',')>0) type,
    name
    from d
      

  6.   

    --1.
    select 
    id,
    [type]=case type when 1 then '一类' when 2 then '甲等' end ,
    name 
    from tt --2.
    select d.id,[type]=t.id,d.name 
    from t join d on charindex(d.id,t.ls)>0