您现在的位置是: 首页 > 后端开发 SqlServer 优化技巧

SqlServer 优化技巧

2020-05-20 后端开发 1534人已围观 2763次浏览

简介SqlServer 优化技巧

查询在A表但是不在B表中的数据

– 效率低,但是容易理解

select distinct A.ID from A where A.ID not in (select ID from B)

– 图解 

select A.ID from A left join B on A.ID=B.ID where B.ID is null

– 逻辑相对复杂,但是效率最高 

select * from B where (select count(1) as num from A where A.ID = B.ID) = 0

 

 

 

很赞哦! (0)

站长推荐

站点信息

  • 网站地图