或者用联合试试 select id ,edu_id,cardno ..usertype from edu_baomin where edu_id=3 unit select name.. from TCARD where cardno in (select cardno from edu_baomim where edu_id=3 and usertype=0)
case when 就可以简单点, 查一个字段,其他的一样 select case b.USERTYPE when '1' then a.name when '0' then b.username endfrom tcard a,edu_baomin b where b.EDU_ID=3 and a.cardno=b.cardno
select id ,edu_id,cardno ..usertype from edu_baomin
where edu_id=3
unit
select name.. from TCARD
where cardno in (select cardno from edu_baomim where edu_id=3 and usertype=0)
select
case b.USERTYPE
when '1' then a.name
when '0' then b.username
endfrom tcard a,edu_baomin b where b.EDU_ID=3 and a.cardno=b.cardno