开发者

mysql problem left join and from_unixtime

开发者 https://www.devze.com 2022-12-23 11:04 出处:网络
I have this开发者_如何学JAVA SELECT COUNT(1) cnt, a.auther_id FROM `posts` a LEFT JOIN users u ON a.auther_id = u.id

I have this开发者_如何学JAVA

SELECT COUNT(1) cnt, a.auther_id
    FROM `posts` a 
    LEFT JOIN users u ON a.auther_id = u.id
    GROUP BY a.auther_id
    ORDER BY cnt DESC
    LIMIT 20

It works fine, but now I want select posts from within the last day. I tried to use

    WHERE from_unixtime(post_time) >= SUBDATE(NOW(),1) 

but it didn't work. Any one have idea why?


This may work:

WHERE FROM_UNIXTIME(post_time) >= SUBDATE(NOW(), INTERVAL 1 DAY)
0

精彩评论

暂无评论...
验证码 换一张
取 消