当前位置:Gxlcms > 数据库问题 > [MySQL]使用EXISTS代替IN

[MySQL]使用EXISTS代替IN

时间:2021-07-01 10:21:17 帮助过:6人阅读

-> EXISTS SELECT * FROM CouponItem AS A WHERE A.CouponId IN(SELECT B.Id FROM Coupon AS B WHERE B.Id<30); SELECT * FROM CouponItem AS A WHERE EXISTS(SELECT B.Id FROM Coupon AS B WHERE B.Id<30 AND A.CouponId=B.Id); #NOT IN -> NOT EXISTS SELECT * FROM CouponItem AS A WHERE A.CouponId NOT IN(SELECT B.Id FROM Coupon AS B WHERE B.Id<30); SELECT * FROM CouponItem AS A WHERE NOT EXISTS(SELECT B.Id FROM Coupon AS B WHERE B.Id<30 AND A.CouponId=B.Id);

[MySQL]使用EXISTS代替IN

标签:log   not   where   from   style   class   weight   使用   mys   

人气教程排行