减去我有两个查询替代在MySQL
1) select count(*) from first where active='1'
2) select count(*)
from first a left outer join second b
on a.pid=b.project_id and a.project_name=b.project_name
where a.entry_date='2014-01-01'
对于第一我正在106和第二我收到86. 我想显示的106-83 = 26,26行。行应包含细节不仅包括计数。 我已经试过不存在和不在。 与此在表的复合键已被使用PROJECT_ID和PROJECT_NAME
我想这一点,但在返回0行发现
select a.project_id, a.project_name
from first a
where a.active='1' and
NOT Exists(
select b.project_id, b.project_name
from first a
left outer join second b on a.pid=b.project_id
and a.project_name=b.project_name
where a.entry_date='2014-01-16');
请帮助,如果任何人有任何想法,如何做到这一点。
'选择从第一一内连接第二个B上a.pid = b.project_id和a.project_name = b.project_name其中a.entry_date = COUNT(*) '2014-01-01'' –
它返回83行作为计数,如何实现其他23行差异 – ajitksharma