Home  >  Article  >  Backend Development  >  数据库只取出一部分的有关问题

数据库只取出一部分的有关问题

WBOY
WBOYOriginal
2016-06-13 13:19:54943browse

数据库只取出一部分的问题
我现在有一张表,属性有fid, content, time 。fid是好友的id, content是好友说的话,每个好友可以说很多句话,好友也有很多,现在假设有很多好友,每个好友说了很多话,怎么能按时间取出任意多的数据。我现在只能foreach一下fid然后在push到一个新数组里面,然后再按time排序,然后取出期中的一些,但是这样效率太低了,有没有别的方法呢

------解决方案--------------------
是全部取出数据,还是取指定个数的数据?
------解决方案--------------------
select fid,content,time from table order by time desc
------解决方案--------------------
根据时间排序啊

order by time
------解决方案--------------------
建议你贴出你的表结果和你的代码,这样别人才能知道你想要干什么。
------解决方案--------------------
关键代码发出来看一下

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn