显示最近 7 天内添加的查看次数最多的条目 [英] Show most viewed entries that have been added in the last 7 days

查看:55
本文介绍了显示最近 7 天内添加的查看次数最多的条目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示过去 7 天内添加的查看次数最多的条目.

I want to show the most viewed entries that have been added in the last 7 days.

我试过了:

SELECT active, date_created, comments, views, URL, title, category, image1
FROM `tbl_news` 
WHERE DATE_SUB(curdate(), INTERVAL 1 WEEK) <= `date_created` 
ORDER BY `views` DESC LIMIT 10;

但没有成功.

日期采用标准格式:1310824884

The date is in the standard format: 1310824884

推荐答案

日期采用标准格式:1310824884

The date is in the standard format: 1310824884

这不是 mySQL 的标准日期格式.如果它存储为时间戳,请使用 FROM_UNIXTIME() 使其成为一个合适的 mySQL 日期进行比较.

That is not mySQL's standard date format. If it's stored as a time stamp, use FROM_UNIXTIME() to make it a proper mySQL date to compare against.

这篇关于显示最近 7 天内添加的查看次数最多的条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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