mysql 中用 inner join 代替关键字 intersect
在mysql中不支持关键字intersect,可以用 inner join 来代替intersect的作用。
例如:选择选修了课程号为‘101’和‘102’的学生的学号。
sql sever 中可用语句 select sno from sc where cno = 101 intersect select sno from sc where cno = 102;
mysql 中替换为 select sc1.sno from sc sc1 inner join sc sc2 using(sno) where sc1.cno = 101 and sc2.cno = 102;
mysql 和 sql sever 中 都可用
select sno from sc where cno = 101 and sno in ( select sno from sc where cno = 102);

浙公网安备 33010602011771号