修改现有的MySQL查询时遇到问题,每次尝试我都有问题 不断收到解析错误或MySQL警告/错误。我看过以前的 问题和尝试了各种各样的事情,但似乎无法正确和它 必须是简单的事情。
以下是工作查询
mysql_query("
SELECT count(list_id) AS counter
FROM bookings
WHERE
'". $date_form . ($i - ($startday + 1)) ."' BETWEEN checkin_date
AND DATE_SUB(checkout_date, INTERVAL 1 DAY)
AND appmt_id = ". mysql_real_escape_string($_POST['appmt_id'])
);
我想简单地添加:
AND is_deleted = 0
is_deleted是表中包含0或1
的字段尝试了括号,引号等 - 为简单的问题道歉并感谢 提前寻求帮助。
答案 0 :(得分:3)
如果调用该字段,这应该可以正常工作" is_deleted":
mysql_query("
SELECT count(list_id) AS counter
FROM bookings
WHERE '" . $date_form . ($i - ($startday + 1)) . "' BETWEEN checkin_date AND DATE_SUB(checkout_date, INTERVAL 1 DAY)
AND appmt_id = " . mysql_real_escape_string($_POST['appmt_id']) . "
AND is_deleted = 0
");