我已经编写了MySQL查询来检查给定的开始和结束时间之间的任何行,但它不起作用,有人帮我找到这个错误吗?
查询:
SELECT *
FROM users
WHERE user_id='".$input['guard']."'
AND (start_time >= '".$startDateTime."' OR finish_time <= ".$finishDateTime."'
错误:
语法错误或访问冲突:1064 SQL语法中出错;查看与您的MySQL服务器版本相对应的手册,以获得在&#39;&#39;附近使用的正确语法。在第3行(SQL:SELECT * FROM users WHERE user_id =&#39; 13&#39; AND(start_time&gt; =&#39; 2014-10-20 10:30:00&#39; OR finish_time&lt; =& #39; 2014-10-20 21:30:00&#39;)
答案 0 :(得分:0)
$guard=$input['guard'];
$sql="SELECT *FROM users WHERE user_id='$guard' AND (start_time >='$startDateTime' OR finish_time <='$finishDateTime')";