同张表中同时查询两个字段显示一个字段,对两个字段进行按时间排序

Posted 林夕Emma

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了同张表中同时查询两个字段显示一个字段,对两个字段进行按时间排序相关的知识,希望对你有一定的参考价值。

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

 

以上是关于同张表中同时查询两个字段显示一个字段,对两个字段进行按时间排序的主要内容,如果未能解决你的问题,请参考以下文章

一张表中的ID对应另一张表中的两个字段怎么查询

SQL关联两张表查数据,结果只显示一条。

mysql同一张表中两个字段 关联另一张表的相同字段 查询出两个值

DB2中2张表中有同一个字段名 要同时查询出2个字段怎么解决

oracle中两张表中的两个字段值的模糊比对

THINKPHP怎么查询一张表中某个字段数据重复次数最多的前几名!