select * from a where bid in (select bid from b group by bid having count(bid)<2)
select * from a where bid not in(select bid from b group by bid having count(1)=1)
select * from t_BiddingInfo where BiddingId not in (select max(BiddingId) from t_TenderInfo group by BiddingId) 这样查询可以查出来不在另外一张表的的记录了,现在我还想查出来上面这句话得到的结果中在2个日期之间的 BiddingId的记录
select a.* from a where bid not in (select distinct bid from b)
select * from t_BiddingInfo where getDate() between BiddingBeginDate and BiddingEndDate order by BiddingId desc not in (select max(BiddingId) from t_TenderInfo group by BiddingId)这样写提示 消息 156,级别 15,状态 1,第 1 行 关键字 'not' 附近有语法错误。
select a.* from a where bid not in (select distinct bid from b)select a.* from a where bid not in (select bid from b group by bid having count(1) = 1)
select * from t_BiddingInfo where getDate() between BiddingBeginDate and BiddingEndDate order by BiddingId desc not in (select max(BiddingId) from t_TenderInfo group by BiddingId)
SELECT * FROM A WHERE NOT EXISTS( SELECT 1 FROM B WHERE A.BID=BID GROUP BY BID HAVING COUNT(1)<2)
语法上应该是这样写的: select * from t_BiddingInfo where getDate() between BiddingBeginDate and BiddingEndDate and BiddingId not in (select max(BiddingId) from t_TenderInfo group by BiddingId) order by BiddingId desc
*
from a
where bid
in (select bid from b group by bid having count(bid)<2)
这样查询可以查出来不在另外一张表的的记录了,现在我还想查出来上面这句话得到的结果中在2个日期之间的
BiddingId的记录
select * from t_BiddingInfo where getDate() between BiddingBeginDate and BiddingEndDate order by BiddingId desc not in (select max(BiddingId) from t_TenderInfo group by BiddingId)这样写提示
消息 156,级别 15,状态 1,第 1 行
关键字 'not' 附近有语法错误。
select * from t_BiddingInfo where
getDate() between BiddingBeginDate and BiddingEndDate order by BiddingId desc
not in (select max(BiddingId) from t_TenderInfo group by BiddingId)
FROM A
WHERE NOT EXISTS(
SELECT 1
FROM B
WHERE A.BID=BID
GROUP BY BID
HAVING COUNT(1)<2)
select * from t_BiddingInfo where
getDate() between BiddingBeginDate and BiddingEndDate and
BiddingId not in (select max(BiddingId) from t_TenderInfo group by BiddingId)
order by BiddingId desc