
能不能把两个where in语句用OR连接,作为一个select语句的两个条件 200
2017-08-09 · 知道合伙人数码行家

可以把两个where in 用or连接。
实现方法如下:
创建表插入数据:
create table test
(teamid int,
name varchar(10))
insert into test values (1,'张三')
insert into test values (1,'李四')
insert into test values (2,'王五')
insert into test values (2,'赵六')
insert into test values (3,'孙七')
insert into test values (3,'杨八')
insert into test values (4,'刘九')
执行第一个where in
select * from test where teamid in (1)
执行第二个where in
select * from test where teamid in (2,3)
将两个where in用 or 连接
select * from test where teamid in (1) or teamid in (2,3)
由此可见,是可以把两次的结果合并成一个完整的结果。
你好,本题已解答,如果满意
请点右下角“采纳答案”。