我在表中的日期为TIMESTAMP
,类似2016-05-28 18:39:00
现在我正在尝试从日期= 2016-05-28
这是我的查询
$getReport = $db->prepare('SELECT a.proId, a.userId, DATE(a.date), a.status, a.canceledBy, b.id, b.pName, b.pPrice FROM purchaseshistory AS a INNER JOIN products AS b ON(a.proId=b.id) WHERE a.date=?');
$getReport->bind_param('i', $dateOfBirth);
$getReport->execute();
$getReport->bind_result($proId, $userId, $date, $status, $canceledBy, $id, $pName, $pPrice);
$getReport->store_result();
while ($getReport->fetch()) {
日期来自这里
$dateOfBirth = $_POST['dateOfBirth'];
结果为空
答案 0 :(得分:0)
您已在SELECT中将a.date转换为DATE,但在WHERE子句中没有,我建议您修改查询,如下所示:
SELECT
ph.proId, ph.userId, DATE(ph.date), ph.status, ph.canceledBy,
p.id, p.pName, p.pPrice
FROM purchaseshistory AS ph
INNER JOIN products AS p ON ph.proId = p.id
WHERE DATE(ph.date) = ?
答案 1 :(得分:0)
可能需要正确的日期格式
SELECT a.proId, a.userId,
DATE(a.date), a.status, a.canceledBy, b.id, b.pName, b.pPrice
FROM purchaseshistory AS a
INNER JOIN products AS b ON(a.proId=b.id)
WHERE date_format(a.date,'%Y-%m-%d') = ?