看了sql,大概明白LZ什么意思了,要实现找出有最新回帖的前10个帖子的信息吧。其实这个分两个sql来查最合适,先通过forum_post找出最新回帖的10个帖子的id,
在根据帖子id查找forum_thread即可。select * from forum_post where first=1 order by lastpost desc limit 1,10;
因为每个帖子的一楼只有一个,因此可以这么查。注意要建一个联合索引(first,lastpost),
这样查询时会用到索引。
select * from forum_thread where tid in(xxx,yyy);希望能对你有帮助
在根据帖子id查找forum_thread即可。select * from forum_post where first=1 order by lastpost desc limit 1,10;
因为每个帖子的一楼只有一个,因此可以这么查。注意要建一个联合索引(first,lastpost),
这样查询时会用到索引。
select * from forum_thread where tid in(xxx,yyy);希望能对你有帮助
解决方案 »
- 请帮助我看看 查询问题。
- 关于MySQL的Threads_connected不断增加的问题
- MYSQL 真的那么强大而好学??高分探讨。
- 弱问关于MYSQL commandline的问题
- 数据插入效率讨论
- MYSQL问题
- 启动mysql.exe时出现ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
- mysql如何实现嵌套查询
- 怎么写这样的SQL语句?很难!!
- create table 字段default值的问题
- 导入SP时候Locate报collations错误
- mysqldump时这个错误什么意思啊
贴出 explain select ...
贴出 show index from ...以供分析。
直接把SQL语句放到MYSQL中执行,贴出结果,按楼上的!