where 日期 = today and 中奖 = 1
group <a href="https://www.baidu.com/s?wd=by&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y4m16knhmkmH-BnhNhnWT30ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3En1c3P1ckrjbzPjfvPH61nHcd" target="_blank" class="baidu-highlight">by</a>中奖期数 as zqs
order <a href="https://www.baidu.com/s?wd=by&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1Y4m16knhmkmH-BnhNhnWT30ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3En1c3P1ckrjbzPjfvPH61nHcd" target="_blank" class="baidu-highlight">by</a>zqs
第一、如果是随机去除,可以:1、取出表总条数n2、在应用程序中生成n个随机数(区间在0到n-1)3、去数据库中把这些记录取出来第二、用优化mysql查询语句的方法网上基本上都是查询max(id) * rand()来随机获取数据。SELECT *FROM `table` AS t1 JOIN (SELECT ROUND(RAND() * (SELECT MAX(id) FROM `table`)) AS id) AS t2WHERE t1.id >= t2.idORDER BY t1.id ASC LIMIT 5但是这样获得的是5条连续的记录,解决办法只能是每次查询一条,查询5次。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)