select start,end from
(
select start,end from table1
union all select end,start from table1
) group by start,end having count(start)>1
(
select start,end from table1
union all select end,start from table1
) group by start,end having count(start)>1
解决方案 »
- 分页存储过程问题
- 为什么这个sql语句有错
- 视图更新的问题
- 簡單語句的效率問題,高手指點
- 急问,如何让Enterprise manager备份时候不显示所有硬盘上文件!
- EXCEL2000表导入到SQLserver2000的问题
- ssh项目链接数据库出错很严重!
- 这样选出的记录如何过滤?
- 动态修改数据库记录集(多个表组合而得)中的内容,有什么解决方案得到这个效果吗?先在这儿谢谢大家了!(ADO.NET 1.1 + SqlServer 2000
- 请叫关于触发器的问题,能帮我解决的另外给分!
- 按“分数”排序,等级分别为:10%优,20%良,60%合格,10%不合格。如何把等级存到“等级”一列?
- 急求两条SQL语句,非常感谢!!!!!!!!!!!!!!!!!!!!!!!
insert #aa values(1,'aaa','bbb')
insert #aa values(2,'aaa','bbb')
insert #aa values(3,'bbb','aaa')
insert #aa values(4,'aa','bb')
insert #aa values(5,'aa','bb')
insert #aa values(6,'a','bbb')
insert #aa values(1,'bb','aa')
select start,[end] from
(
select start,[end] from #aa
union all select [end],start from #aa
) emp group by start,[end] having count(start)>1----------------------------------------------
start end
---------- ----------
bb aa
bbb aaa
aa bb
aaa bbb(4 row(s) affected)
select start,end from
(
select start,end from table1
union all select end,start from table1
) aa -- 给一个别名
group by start,end having count(*)>1
declare @end varchar(50)
DECLARE zxg_cursor CURSOR FOR
SELECT start,end
FROM table1 OPEN zxg_cursor
FETCH NEXT FROM authors_cursor
INTO @start, @end
WHILE @@FETCH_STATUS = 0
BEGIN
select * from table1 where (start=@start and end=@end) or (start=@end and end=@start) FETCH NEXT FROM titles_cursor INTO @start,@end
END CLOSE zxg_cursor
DEALLOCATE zxg_cursor
select start,[end] from
(
select start,[end] from yourtable
union all select [end],start from yourtable
) emp group by start,[end] having count(start)>1