间接语句
Cno Cpno1 52 NULL3 14 65 76 NULL7 68 6
create table tb(cno int, Cpno int)insert into tb values(1 , 5)insert into tb values(2 , NULL)insert into tb values(3 , 1)insert into tb values(4 , 6)insert into tb values(5 , 7)insert into tb values(6 , NULL)insert into tb values(7 , 6)insert into tb values(8 , 6)goselect t1.cno , cpno = (select cpno from tb t2 where t2.cno = t1.cpno) from tb t1/*cno cpno ----------- ----------- 1 72 NULL3 54 NULL5 66 NULL7 NULL8 NULL(所影响的行数为 8 行)*/select * from ( select t1.cno , cpno = (select cpno from tb t2 where t2.cno = t1.cpno) from tb t1) twhere cpno is not null/*cno cpno ----------- ----------- 1 73 55 6(所影响的行数为 3 行)*/drop table tb