我这想通过一条sql语句,查询两表中,不同的数据。 select billno from declarebill dl,(select billno from checkcapital)cp where dl.Check_Money=1 and dl.billno<>cp.billno 我的意思是declarebill中凡是符合Check_Money=1,并且是dl.billno<>cp.billno不相等的数据,但好像执行出来的结果不对,应该如何写个sql语句呢?
select billno from declarebill dl where billno not in (select billno from checkcapital) and Check_Money=1
== 思想重于技巧 ==
select dl.billno from declarebill dl left join checkcapital cp on dl.billno=cp.billno where dl.Check_Money=1 and cp.billno is null
== 思想重于技巧 ==
子查询有问题,没有看到记录及正确结果,TRY: select dl.billno from declarebill dl left join checkcapital cp on dl.billno=cp.billno where dl.Check_Money=1 and cp.billno is null
select a.billno from declarebill as a left join checkcapital as b using(billno) where a.Check_Money = 1 and b.billno is null;
from declarebill dl
where billno not in (select billno from checkcapital)
and Check_Money=1
from declarebill dl left join checkcapital cp on dl.billno=cp.billno
where dl.Check_Money=1 and cp.billno is null
select dl.billno from declarebill dl left join checkcapital cp on dl.billno=cp.billno
where dl.Check_Money=1 and cp.billno is null
select a.billno from declarebill as a left join checkcapital as b using(billno) where a.Check_Money = 1 and b.billno is null;