1. 程式人生 > >同張表中同時查詢兩個字段顯示一個字段,對兩個字段進行按時間排序

同張表中同時查詢兩個字段顯示一個字段,對兩個字段進行按時間排序

principal mount sel con AC code rom inter nbsp

select b.bid_name as bidName,bd.repayment_way as depict,r.exact_repayment_time as time,
r.should_repayment_principal as amount, 待收本金 as typeContent
from repayment r
INNER JOIN bid b
ON r.bid_id = b.bid_id
INNER JOIN bid_details bd
ON b.bid_id = bd.bid_id
where r.user_id=1 and r.state = 1
UNION
select
b.bid_name as bidName,bd.repayment_way as depict,r.exact_repayment_time as time, r.should_repayment_interest as amount, 待收利息 as typeContent from repayment r INNER JOIN bid b ON r.bid_id = b.bid_id INNER JOIN bid_details bd ON b.bid_id = bd.bid_id where r.user_id=1 and r.state = 1 ORDER BY time

同張表中同時查詢兩個字段顯示一個字段,對兩個字段進行按時間排序