我想做一个限制发帖功能 但是mysql数据库的addtime字段的值是unix时间戳(例如:1238853633)把unix时间戳转换成普通时间格式用from_unixtime函数select count(*) as id from table where from_unixtime(addtime)=当天时间请问当天时间怎么表示呀  我只知道这个思路但是不知道具体怎么写这个mysql语句

解决方案 »

  1.   

    select count(*) as id from table where from_unixtime(addtime)=date("Y-m-d");
      

  2.   

    当前的时间 now()对你的情况,用 TO_DAYS 好些
    TO_DAYS(from_unixtime(addtime)=TO_DAYS(NOW())
      

  3.   

    今天
    select * from 表名 where to_days(时间字段名) = to_days(now());
      

  4.   

    //我想实现的功能是:个人用户每天只可以发布4条信息
    $sqluser=mysql_query("select * from house_user where uid={$user_id}");
    $infouser=mysql_fetch_array($sqluser);
    if ($infouser[userclass]==1 or $infouser[userclass]==3)//判断用户身份,是个人还是中介
    {
       $sqlcs=mysql_query("select count(*) as id from house_cs where cs_uid={$user_id} and TO_DAYS(from_unixtime(cs_addtime)=TO_DAYS(NOW())");
       $infocs=mysql_fetch_array($sqlcs);
       if ($infocs[id]> 4)//统计该用户今日发帖
       {
      echo "<script language='javascript'>alert('您不能多发4条');window.history.go(-1);</script>";
       }
       
    }各位帮我看看代码呀
      

  5.   

    这句php语句不能限制发帖我就把 select count(*) as id from house_cs where TO_DAYS(from_unixtime(cs_addtime)=TO_DAYS(NOW())  这句话放到mysql里运行 报错如下:
    [SQL] select count(*) as id from house_cs where TO_DAYS(from_unixtime(cs_addtime)=TO_DAYS(NOW())[Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
      

  6.   

    select count(*) as id from table where TO_DAYS(from_unixtime(addtime))= TO_DAYS(now())
      

  7.   

    select count(*) as id from table where TO_DAYS(from_unixtime(addtime))= TO_DAYS(now())  不是和我写的一个意思吗?请各位帮忙看看呀
      

  8.   

    噢,我漏了个')',你也漏了个')'
    select count(*) as id from house_cs where TO_DAYS(from_unixtime(cs_addtime))=TO_DAYS(NOW())