我想找出 10 条按某种顺序排列好的记录,并以 foo 为 10 条记录的中心点。应该如何操作呢?基本语句类似:select * from tbl order by win limit 10关键在于如何让这 10 条记录以 id=foo 记录为中间那一个行?
解决方案 »
- 配置Proxool的时候出现异常Proxool Provider unable to load JAXP configurator file: ProxoolC
- 新手请教:关于比较判式的两边均采用聚合分析的子查询
- mysql+php环境正常运行一段时间后,php连接mysql失败,需重启电脑才行
- MySQL 日期格式转换
- 为什么用了limit还会进行全表扫描?
- 为什么数据库不乱码
- 急求解决Myeclipse的注册码问题
- 论坛的表问题
- 求大神列举mysql数据库分布式部署架构
- linux环境下没发现mysql "查询日志"“-log”
- 如何用sql语句更新数据表中某字段的数据类型?
- 在MySql中,怎么调用有输出参数的存储过程,并得到输出参数的值呢???
create temporary table tmp (id int not null auto_increment primary key,其他tbl的字段) select * from tbl where id = 'foo' order by win desc;select ceiling(max(id) + min(id)/2+1) from tmp into @v_id;
select * from tmp where id >=@v_id limit 5
union all
select * from tmp where id < @v_id limit 5;
(
select * from tbl where win <= (select min(win) from tbl where id='foo') order by win desc limit 6
union
select * from tbl where win > (select min(win) from tbl where id='foo') order by win limit 5
) as a
order by win;[align=center]==== 思想重于技巧 ====
[/align]
1-10 中间的那个数是几?上面SQL 是 11 条记录以 id=foo 记录为中间[align=center]==== 思想重于技巧 ====
[/align]
要用store precudure 了,不是仅用SQL能做到了, 不象oracle中有rowno[align=center]==== 思想重于技巧 ====
[/align]