CREATE CURSOR member(id c(12),tuijianid c(12))
INSERT INTO member(id,tuijianid) values('vip1','vip0')
INSERT INTO member(id,tuijianid) values('vip2','vip1')
INSERT INTO member(id,tuijianid) values('vip3','vip2')
INSERT INTO member(id,tuijianid) values('vip4','vip0')
INSERT INTO member(id,tuijianid) values('vip5','vip3')
INSERT INTO member(id,tuijianid) values('vip6','vip5')
INSERT INTO member(id,tuijianid) values('vip7','vip6')
INSERT INTO member(id,tuijianid) values('vip8','vip7')
INSERT INTO member(id,tuijianid) values('vip9','vip2')
INSERT INTO member(id,tuijianid) values('vip10','vip9')
**大家注意了,问题来了。
**方法1:
select distinct RTRIM(tuijianid) as tjid from member INTO CURSOR aa
select ID from member where rtrim(ID) NOT in (SELECT tjid FROM aa)
**结果是:vip4,vip8,vip10
select ID from member where RTRIM(ID) not in (select distinct RTRIM(tuijianid) as tjid from member)
**方法2:
**结果是:vip4,vip8,,,,为什么vip10不出现在这?VPF9