MySQL两个表联合查询并按时间排序

有一张资金记录表,一张金币记录表,想以时间为单位,降序合并排列他们之间的信息,查询SQL如下:

select * from (select * from t_money_logs union select * from t_gold_logs) as c order by create_time desc;

原地址:https://www.cnblogs.com/gentsir/p/5166506.html

select * from (select 
o.ORDER_NUM as order_sn,
o.GOODS_NAME as GOODS_NAME,
o.CREATE_TIME as CREATE_TIME,
"goods" as type
from ayy_order o union select 

s.ORDER_NUM as order_sn,
s.GOODS_NAME as GOODS_NAME,
s.CREATE_TIME as CREATE_TIME,
"service" as type
from ayy_service_order s) as c order by CREATE_TIME desc;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值