how to execute the query that include date function(MySQL)
I got a query including two variable parameters. It cannot be executed successfully. Anyone help me to have a look. thanks
$queryUpdateScreeningMai开发者_高级运维leddate = "UPDATE screening
SET maileddate = {date('Y-m-d', strtotime($mailed_date[$screeningId]))}
WHERE user_id IN (
select s.id
from (
SELECT users.id
FROM users
INNER JOIN screening ON
users.id = screening .user_id
AND screening.id = {$screeningId}
) as s)
AND date BETWEEN '2011-05-15' AND '2011-11-15'";
$_db->executeQuery($queryUpdateScreeningMaileddate);
Curly brace {}
syntax only works for variables, it doesn't work for function calls. You will have to break the string up like this:
$queryUpdateScreeningMaileddate = "UPDATE screening
SET maileddate = '".date('Y-m-d', strtotime($mailed_date[$screeningId]))."'
WHERE user_id IN (
select s.id
from (
SELECT users.id
FROM users
INNER JOIN screening ON
users.id = screening .user_id
AND screening.id = {$screeningId}
) as s)
AND date BETWEEN '2011-05-15' AND '2011-11-15'";
$_db->executeQuery($queryUpdateScreeningMaileddate);
精彩评论