Do both the following queries always give the same results? If not, why not?
1)
select PayFrequencyTypeID, PayFrequencyDesc
from db_uspaybo.tblpayfrequency
where (PayFrequencyTypeID,1) not in (
select payfrequencytype,1
from tblcustomerpayapproval
where fedtaxid='903008887' and payrollyear=year(curdate())
);
2)
select payfrequencytypeid
from tblpayfrequency
where not exists (
select distinct payfrequencytype
from tblcustomerpayapproval
);
Thanks in advance.
I think this is what you want with ‘Not Exists’
A.Id and B.Id here is the Pk and FK that connect these tables.(I don’t know the exact field name)
select payfrequencytypeid from tblpayfrequency A
where not exists ( select *
from tblcustomerpayapproval B where A.Id=B.Id and B.fedtaxid=’903008887′ and B.payrollyear=year(curdate()));