直接上表好吧
表一school:
create table school
(ino int ,
name char(20),
classno int
)
往school中插入数据
insert into school values(1,"liaoyiqi",2101),(2,"wenjie",2109),(3,"zhoudayuan",2108)
表一school的数据:
表二stu :
create table stu
(ino int ,
name char(20),
classno int
)
往stu插入数据
INSERT INTO stu VALUES (1,"liaoyi",2101),(5,"wen",2109),(2,"zhouda",2108)
表stu的数据
select * from school t where t.ino in (select ino from stu u where t.ino=u.ino)
如果在school中的表中的ino在stu里面的ino存在则返回school的中所对应的行
查询如图 所示
如果只是select 1 in (1,2,4,5)只会返回一个boolen值就是0或1
如图
select 1 in (2,3,4,5)