两张表合并加标识根据ID

select fpt_point,dt,(case [type] when 1 then '充值' when 0 then '消费' else 'error' end)as [type] from
(select fpd.fpt_point,fpd.dt,'1' as [type] from td_fullPointDetail fpd  where fpd.mem_id=1
union
select cpd.cpd_point,cpd.dt,'0' as [type] from td_consumePointDetail cpd where cpd.mem_id=1)as a

你可能感兴趣的:(id)