当前位置:编程学习 > C#/ASP.NET >>

sql 查询语句

请教高手 我如何查询数据库中一个字段已经存在2条包含相同字符的字段呢? 如图:第2、3条Tsinghua University已经同时存在了,我该怎么用查询语句表达???

sql --------------------编程问答-------------------- select s_name from 表名 group by s_name having count(s_name)>2 --------------------编程问答-------------------- 觉得不好理解可以当成表的属性来理解

select t.s_name
from
(
  select s_name,count(1) as nums 
  from 
  t_table 
  group by s_name 
)
where t.nums =  2
--------------------编程问答--------------------
引用 2 楼 nice_fish 的回复:
觉得不好理解可以当成表的属性来理解

SQL code?123456789select t.s_namefrom(  select s_name,count(1) as nums   from   t_table   group by s_name ) T where t.nums =  2


少了一个T --------------------编程问答--------------------
引用 1 楼 u010049561 的回复:
select s_name from 表名 group by s_name having count(s_name)>2
 
正解 --------------------编程问答-------------------- select s_name,count(1) as num from table where num>1 group by id --------------------编程问答-------------------- 5楼的  你测试来吗就给人家回复 明明都有错误 --------------------编程问答-------------------- select * from (select s_name,COUNT(s_id) as 'nums' from tableName group by s_name )t where t.nums >2
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,