表数值如下
a b c
1 11 1 01
2 12 1 01
3 12 2 01
4 13 1 01
5 13 2 02现在要取出table表里面 a列 和 c列重复的 比如上面 a列 12 对应 c列两个01取出来的目的是不允许 a列和c列有重复的值.
a b c
1 11 1 01
2 12 1 01
3 12 2 01
4 13 1 01
5 13 2 02现在要取出table表里面 a列 和 c列重复的 比如上面 a列 12 对应 c列两个01取出来的目的是不允许 a列和c列有重复的值.
select * from tb a where not exists(select 1 from tb where a.a = a and a.c = c and a.id >id)
on a.a=b.a and a.c=b.c
where exists (select * from @table where a = t.a and c = t.c and id <> t.id )