加入收藏 | 设为首页 | 会员中心 | 我要投稿 湖南网 (https://www.hunanwang.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程 > 正文

not in 与in 做大数据的时候可以用来替换下

发布时间:2021-01-12 07:30:40 所属栏目:编程 来源:网络整理
导读:本日PHP站长网 52php.cn把网络自互联网的代码分享给各人,仅供参考。 create table #table1 (name varchar(20),dis varchar(100))create table #table2 (name varchar(20),dis varchar(100))insert into #table1 select '

以下代码由PHP站长网 52php.cn网络自互联网

此刻PHP站长网小编把它分享给各人,仅供参考

create table #table1 (name varchar(20),dis varchar(100))
create table #table2 (name varchar(20),dis varchar(100))

insert into #table1 select 'a','b' union select 'b','c' union select 'd','e' union select 'f','g'
insert into #table2 select 'a1','b1' union select 'b1','c1' union select 'd1','e1' union select 'f1','g1'

select * from #table2 where dis not in(select name from #table1)

select * from #table2  as a
left join #table1 as b on a.dis=b.name
where b.name is null

/*
select * from 表A where 列 not in(select 列 from 表B)

替代要领 表A 与 表B 举办join关联  让B 列为null时 则表A稀有据 表B没有。
之前做数据转储的时辰想到的,数据量很大的时辰可以这样 服从很高

select * from 表A  as a
left join 表B as b on a.列=b.列
where b.列 is null
*/

以上内容由PHP站长网【52php.cn】网络清算供各人参考研究

假如以上内容对您有辅佐,接待保藏、点赞、保举、分享。

(编辑:湖南网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读