现在有两个表t1,t2 t1表中有c1,c2,c3....字段,t2种有c3,c4....和其他字段 where条件都在t1表里, 以前语法: select t1.*,t2.* from t1 inner jion t2 on t1.c3=t2.c3 where t1.c1=1 and t1.c2=1 以前t2中的c3都是唯一的,现在可能不唯一,如果t2中的c3出现两条记录的话,结果也回出现两条重复记录。 过滤掉结果中的重复应该怎么写? 请高人指导!
with t as
(select * from t2 a where not exists(select 1 from t2 where 主键>a.主键 and c3=a.c3))
select t1.*,t.*
from t1 inner jion
t on t1.c3=t.c3 and t1.c1=1 and t1……
[/Quote]
with t as
(select * from t2 a where not exists(select 1 from t2 where 主键>a.主键 and c3=a.c3))
select t1.*,t.*
from t1 inner jion
t on t1.c3=t.c3 and t1.c1=1 and t1.c2=1