select 'A' as F from AA
union
select 'B' from AA
union
select 'C' from AA
union
select 'D' from AA
......
select 'X' from AA
union
select 'Y' from AA
union
select 'Z' from AA
然后:
select distinct ID,Field2
from B,(select F from Q,A where instr(Field1,F)>0) t
where instr(Field2,F)>0
求B中所有含有一个或以上的表A中那条记录中字段Field1中的数据集合中的一个字符的记录
呵呵,没有理解你的意思,
TRY:
SELECT A.* FROM TT A INNER JOIN
(SELECT ID FROM TT B GROUP BY ID HAVING COUNT(*)=1) B
ON A.ID=B.ID