MySQL数据库ties表中记录日期的字段名设为tdate 类型是date型(格式为2011-5-15) 在php文件中想要选出所有日期为当前日期的记录 这条SQL语句要怎么写?

解决方案 »

  1.   

    $SQL = 'SELECT * FROM `ties` WHERE `tdate` = "'.date('Y-m-d').'"';
      

  2.   

    谢谢,分号改了一下 写成了这样$strSQL = "select count(*) from ties where tdate = '".date(Y-m-d')."'";可以通过
    那想要匹配昨天的日期要怎么样写?
      

  3.   

    发错了 是这样的$strSQL = "select count(*) from ties where tdate = '".date('Y-m-d')."'";
      

  4.   

    $strSQL = "select count(*) from ties where tdate = '".date('Y-m-d',strtotime('-1day'))."'";
      

  5.   

    $strSQL = "select count(*) from ties where tdate = '".date('Y-m-d',time() - 86400)."'"; //当前时间戳减去一天的秒数86400