http://www.hanyu123.cn/html/c61/6790.html 一.查某一列(或多列)的重复值.(只可以查出重复记录的值,不能查出整个记录的信息) 例如:查找stuid,stuname重复的记录: select stuid,stuname from stuinfo group by stuid,stuname having(count(*))>1 二.查某一列有重复值的记录.(此方法查出的是所有重复的记录,如果有两条记录重复的,就查出两条) 例如:查找stuid重复的记录:…
表结果如图 )) ,'Sky,Blue,Water' ,'Book,Apple,Shirt' ,'Cup,Yellow,org' ,'box,phone,paper' GO SELECT id,SUBSTRING(A.NAME,B.number,CHARINDEX(',',a.NAME+',',b.number)-b.number) AS [name] FROM T AS A JOIN master.dbo.spt_values AS B )=',' 查询结果如下…
一棵树的层次结构都在一张表内,当有这样的需要的时候.. 可以这样玩: <!-- DepartmentDTO 对象对应 department表_查询sql --> <sql id="department_select_sql"> with ldepartment as ( select dept_id, parent_id, 0 as dept_level, row_number()over(order by getdate()) as orderid from…