两个表结构相似的表进行union all

select rowid as numid,
       b.id as bid,
       1 as btype,
       b.serialnumber,
       b.name,
       b.upperlimit,
       null as timelimit,
       b.totalcash,
       b.ispublic,
       b.isinfopublic,
       b.publishdate,
       b.area,
       b.status,
       b.PAYOUT_RATE,--比例
       to_char(b.BEIGIN_DATE,'yyyy-MM-dd') as  BEIGIN_DATE,--开始日期
       to_char(b.END_DATE,'yyyy-MM-dd') as END_DATE ,--结束日期
       b.direction_type,
       b.jzgl_type,
       1 as donation_type
  from jzgl_beneficiary b where b.use_flag = 1
union all
select rowid as numid,
       p.id as bid,
       0 as btype,
       p.serialnumber,
       p.projectname,
       0,
       p.timelimit,
       p.totalcash,
       p.ispublic,
       p.isinfopublic,
       p.publishdate,
       p.area,
       p.status,
       p.PAYOUT_RATE,--比例
       to_char(p.BEIGIN_DATE,'yyyy-MM-dd') as  BEIGIN_DATE,--开始日期
       to_char(p.END_DATE,'yyyy-MM-dd') as END_DATE ,--结束日期
       p.direction_type,
       p.jzgl_type,
       2
  from jzgl_benefitproject p where p.use_flag = 1;

 

你可能感兴趣的:(UNION ALL)