如test表中数据如下:
执行sql语句,但不取id为2和3的数据,可用如下:
select * from test where id not in (2,3)执行结果:
1、用minus函数的方式:
select
*
from
CMN_FUND
where
FUND_CODE_ in
(select FUND_CODE_ from CMN_FUND minus select FUND_CODE_ from CMN_PROMOTION_FUND where FUND_CODE_ in
(select FUND_CODE_ from CMN_PROMOTION_FUND where SELLPROMOTE_CODE_ = #{promotionCode}))
and
FUNDCOMP_CODE_ = #{fundCompCode}
order by
FUND_CODE_
2、用not in来处理:
select
f.FUND_CODE_, f.SHORT_NAME
from
CMN_FUND f, CMN_PROMOTION_FUND p
where
f.FUND_CODE_ = p.FUND_CODE_
and
f.FUND_CODE_ not in (SELECT FUND_CODE_ from CMN_PROMOTION_FUND where PROMOTION_CODE = #{promotionCode})
and
f.FUNDCOMPCODE = #{fundCompCode}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)