使用日期的php mysql where子句
有人能帮我做以下事情吗使用日期的php mysql where子句,php,mysql,time,where,sql-update,Php,Mysql,Time,Where,Sql Update,有人能帮我做以下事情吗 $crDate = date("Y-m-d"); $sql="update callrecord set crEndtime = Now() where crUsId = ".$crUsId."AND crDate = ".$crDate; 我试图做的是更新一个表“callrecord”,其中crDate是当前日期。当我把零件拿出来时,它工作得很好 $sql="update callrecord set crEndtime = Now() where crUsId =
$crDate = date("Y-m-d");
$sql="update callrecord set crEndtime = Now() where crUsId = ".$crUsId."AND crDate = ".$crDate;
我试图做的是更新一个表“callrecord”,其中crDate
是当前日期。当我把零件拿出来时,它工作得很好
$sql="update callrecord set crEndtime = Now() where crUsId = ".$crUsId;
这个很好用。但我也要查看当前的日期。有什么帮助吗?您可以使用MySQL函数
curdate()
,而无需在php中进行计算
$sql = "update callrecord set crEndtime = Now()
where crUsId = '$crUsId' AND crDate = curdate()";
您可以使用MySQL函数
curdate()
,而无需在php中进行计算
$sql = "update callrecord set crEndtime = Now()
where crUsId = '$crUsId' AND crDate = curdate()";
我认为您应该尝试在$crDate周围使用单引号。我认为您应该尝试在$crDate周围使用单引号。您通常将日期作为字符串输入,因此需要对其进行引号。例如,
SELECT*FROM Orders,其中OrderDate='2008-11-11'代码>这里。日期时间为“2008-11-1103:29:12”;通常以字符串形式输入日期,因此需要对其进行引用。例如,SELECT*FROM Orders,其中OrderDate='2008-11-11'代码>这里。日期时间为“2008-11-1103:29:12”;