从MySQL获取昨天的查询

时间:2012-10-07 02:06:49

标签: mysql sql

我正在尝试昨天的查询!使用此代码,我今天可以获得查询,但我不知道我该怎么做才能显示昨天的查询:

$t_date = date( 'Y-m-d H:i', $_TIME - (3596 * 24) );
$twall = $db->super_query("SELECT COUNT(*) as c 
                             FROM dle_photo_post 
                            WHERE date > = '$t_date'
                              AND date < = '$t_date' + INTERVAL 24 HOUR 
                              AND moder = '0' ");

$twall = $twall['c'];  

1 个答案:

答案 0 :(得分:0)

试试这个:

SELECT COUNT(*) as c 
FROM dle_photo_post 
WHERE date between 
                date_sub(curdate(), interval 2 day) 
            and date_sub(curdate(), interval 1 day)
    AND moder = '0'