查询日期之间的mysql

时间:2011-03-04 21:49:52

标签: 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

1 个答案:

答案 0 :(得分:1)

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