A表中有一个字的格式是这样的(用逗号分隔开,可能有1个到5个ID):",02,26,50, "
这个字段跟B表的ID对应,B表的段有(ID,Name),
现在想用一SQL将A表中的编号换成B表对应的名称显示出来,请问怎么写,谢谢!

解决方案 »

  1.   

    我想要的是查询A表的所有内容,但要用B表的name来代理显示“,02,26,50,”等ID
      

  2.   

    select name from 表B where id in (select id from 表A)
    不知道行不行,你的表A中的ID内容有点乱!
      

  3.   

    A表中有一个字段是B表ID的组合,最多有5个 比如 “01,02,03,04,05”
    我要在时显示出五个name,而不是查出B表的五条记录
      

  4.   

    select b.name 
    from b
     where b.id in 
    (( select  top 1 left(a.id,2) from a),
    (select  top 1 substring(a.id,4,2) from a),
    (select  top 1 substring(a.id,7,2) from a),
    (select  top 1 substring(a.id,10,2) from a),
    (select  top 1 substring(a.id,13,2) from a))