我有 2 张桌子
table1,它有列
id
sdate
type
类型列可以有 2 个值事件或计划我正在使用此查询来获取总事件和计划的结果
select date_format(sdate, '%m-%d-%Y') as sdate, sum( type ='event') as tevent , sum(type='schedule') as tschedule from table1 where sid ='1' group by (sdate);
表 2 有这些列
id
title
dtime
为了使它们都类似于在联合中使用,我做了这样的事情
select date_format(dtime, '%m-%d-%Y') as sdate ,0 as tevent,0 as tschedule,count(id) as tlog from table2 where sid =1 group by (sdate) ;
我有点困惑,我怎样才能从两个表中获取数据,如果日期相同,它应该在一列中显示数据。