价钱表price
字段有type,firstprice,secondprice
数据表datatable
字段有type,sfzh(身份证),firstorsecond
两个表通过type相连,其中字段firstorsecond的值为first或者second,若为first则价钱为字段firstprice,若为second则价钱为字段secondprice
------解决方案--------------------
- SQL code
select a.[type],a.sfzh,case a.firstorsecond when 'first' then firstprice else secondprice end as firstorsecond from datatable a inner join price bon a1.[type]=B2.[type]