我现在有个表:movie 字段有:id,name,addr...等等 ,我想查询不重复的以name为条件,比如 "abcd" 所有字段的信息,有很多name相同的信息,我只要输出一条,,高手帮忙看看,,感谢,加分.
解决方案 »
- 做了一个表读取的效率测试...
- 怎么把注册信息分成两半插到两个表中?
- 申明一个@Table ,可以不定义这个@Table的表结构,我把另一个表的结构和数据都传给这个@Table吗?
- 如何建立可以更新的视图?谢谢大侠了!
- 一个从三个基础表得到一个查询,比较复杂,请大家帮手实现
- 一个小企业的销售管理系统用那种数据库比较阿?
- sqlsever的哪个版本可安装在win98上?
- 这条SQL语句好难,请大家帮帮忙!
- 为什么我新建的关系不能作查询操作?
- 将节点1的服务移动到节点2后 数据库服务起不来。initerrlog: 无法打开错误日志文件。操作系统错误 = 3(系统找不到指定的路径。)。
- 关于SQL比较问题
- 往SQL 中insert时 字符串中包含单引号怎么解决
id 唯一的话select * from tb t
where not exists(select * from tb where name=t.name and id>t.id)
and name=''
group by name
*
from
movie t
where
not exists(select 1 from movie where name=t.name and id>t.id)
where name='abcd'
group by name
select * from movie a
where not exists
(select * from tb where name=a.name and id>a.id)
where not exists(select * from movie where name=a.name and id>a.id)
and name='abcd' --条件
SELECT ROW_NUMBER() OVER (PATITION BY [NAME] ORDER BY [NAME]) 'MU_ID',* FROM TB
)
SELECT * FROM MU WHERE MU_ID=1
select
*
from
movie t
where
not exists(select 1 from movie where name=t.name and id>t.id)
and
name='abcd'
40秒? 能不能提高点速度呢?我的这个程序是前台调用后台,太慢好像不太好,,我的这个还要模糊查询,,我用like,一样.
WHERE ID =(SELECT MAX(ID) FROM movie WHERE NAME=M.NAME)
AND M.NAME=...... SELECT * FROM movie M
WHERE ID =(SELECT MIN(ID) FROM movie WHERE NAME=M.NAME)
AND M.NAME=......