日期查询之间的mysql [英] mysql between query in dates

查看:50
本文介绍了日期查询之间的mysql的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$currentdate = date("Y-m-d");
$lastweekdate = date("Y-m-d", strtotime("-6 days")); 
$querytopscoreofweek  = 
"SELECT * FROM fb_user WHERE  last_date".
" BETWEEN $lastweekdate AND $currentdate ORDER BY oldscore DESC LIMIT 0,10";

我有这种格式的字段名称 last_date $currentdate = date("Y-m-d");我想执行上面的查询,我希望它返回上周的所有用户,并在 $lastweekdate 和 $currentdate 之间表示,并且 old_score 按降序排列更大,只有 10 个用户,但问题是它没有返回任何用户任何提示 PLZ

i have field name last_date in this format $currentdate = date("Y-m-d"); i want to execute the above query i want it to return all the users of last week and mean between $lastweekdate and $currentdate and which has also old_score greater in descending order and only 10 users,BUT THE PROBLEM IS THAT IT IS NOT RETURNING ANY THING ANY HINT PLZ

推荐答案

SELECT * 
FROM fb_user 
WHERE last_date BETWEEN curdate() AND curdate() - interval 6 day 
ORDER BY oldscore DESC LIMIT 10

这篇关于日期查询之间的mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆