10个回答
展开全部
你是要在一个查询里,一次查询出但凡是字段值重复的列,不知道我是否理解正确了。
select t.字段1,'' 字段2,...,'' 字段n
from t1 t
group by t.字段1
having count(t.字段1)>1
union all
select '' 字段1,t.字段2,...,'' 字段n
from t1 t
group by t.字段2
having count(t.字段2)>1
union all
...
union all
select '' 字段1,'' 字段2,...,t.字段n
from t1 t
group by t.字段n
having count(t.字段n)>1;
select t.字段1,'' 字段2,...,'' 字段n
from t1 t
group by t.字段1
having count(t.字段1)>1
union all
select '' 字段1,t.字段2,...,'' 字段n
from t1 t
group by t.字段2
having count(t.字段2)>1
union all
...
union all
select '' 字段1,'' 字段2,...,t.字段n
from t1 t
group by t.字段n
having count(t.字段n)>1;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1 如果表a 还有其他字段,比如字段c,c可以做主键,保证a表记录重复,如果没有C,自行添加c字段做表a主键
2 select *
from a a1, a a2
where a1.b=a2.b and a1.c<>a2.c
2 select *
from a a1, a a2
where a1.b=a2.b and a1.c<>a2.c
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select * from a where b in (select b from a group by b having count(*)>1)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select b
from A
group by b
having count (*)>1
from A
group by b
having count (*)>1
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select * from A where b in(select b from A group by b having count(b)>1);
刚亲自试过的。
刚亲自试过的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询