select a.id,case a.类型 when '1类' then b.[1类单价]
     when '2类' then b.[2类单价]
     when '3类' then b.[3类单价]
     end as 单价
from a,b
where a.id=b.id       --不知道是不是这么连接,楼主没说明

解决方案 »

  1.   

    select id,case 类型 
    when '1类' then (select [1类单价] from b)
    when '2类' then (select [2类单价] from b)
    when '3类' then (select [3类单价] from b)
    end
    from a
      

  2.   

    楼主的表结构设计不太合理,如果类型一多,或不固定,就只有用动态语句查询建议B表结构改为:
    B结构:ID,类型,单价
      

  3.   

    像上面这样设置的话,查询用join就行了。select a.id,a.类型,b.单价
    from a,b where a.类型=b.类型
      

  4.   

    谢谢 zjcxc(邹建)的帮助,但其实B表中还有其它字段的如果改成你的结构,有多余的数据浪费!请问Access中也可以这样做吗?
    select id,case 类型 
    when '1类' then (select [1类单价] from b)
    when '2类' then (select [2类单价] from b)
    when '3类' then (select [3类单价] from b)
    end
    from a