
你表肯定是根据哪列排序的吧,你要最后100个就根据情况用“升序”还是“降序”排列吧
select是查询的意思
top是指上面的
select top 100意思就是查询前100
order by 列名 desc 意思就是根据列名行降序排列
大概就这样吧 你自己理解下 希望有帮助
一. 你可以试试这个: select * from xx order by rand() limit 100 二. 是利用系统时间来取随机数的代码,用C++写的。你参看一下吧。 你可以把随机数的范围限定在0 -- 100 ,之内,作为数组的下标就可以访问了。 #include <iostream.h> #include <stdlib.h> #include <time.h> int main() { srand((unsigned int) time(NULL)) int i ,j = 1,array[10] while(j != 0) { for(i = 0i <10i++) { array[i] = rand() cout<<array[i]<<endl } cin>>j } system("PAUSE") return 0 }这样的话应该是你数据库的要加个时间字段才对,然后你在sql检索语句按照时间排序只检索最新的100条记录,然后循环判断,你这样是没有错的,或者说你的id是自动编号的,那么越大的肯定是越新。。所以要不就是我上面说的按照时间排序要不就是按照id降序排序检索前100条记录,比如:sql="select top 100 id ,aa from [table] order by id desc"
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)