sql同一个人同一天做的事在两个表怎么查两个表字段不同,但是每个表都有个日期
直接查呗,又不需要连接
select a.*, b.* from a, b where a.id == 这个人id and b.id ==这个人id and a.日期 = 今天 and b.日期=今天
(select a.userName as userName, a.日期 as dateTime, a.做的事情 as things from a where a.日期 = 哪天)
union
(select b.userName as userName, b.日期 as dateTime, b.做的事情 as things from b where b.日期 = 哪天)
如果有创建时间字段,需要按创建时间来排序,可以
select * from (
(select a.userName as userName, a.日期 as dateTime, a.做的事情 as things, a.createTime from a where a.日期 = 哪天)
union
(select b.userName as userName, b.日期 as dateTime, b.做的事情 as things, b.createTime from b where b.日期 = 哪天)
) c order by c.createTime desc
直接进行两张表的联查不就行了
需求一点也不清楚啊
哪两张表 两张表有哪些字段