“sql语法错误;查看与mysql服务器版本“php问题与时间比较”对应的手册

ma8fv8wu  于 2021-06-21  发布在  Mysql
关注(0)|答案(2)|浏览(298)

每次我尝试格式化一个php mysqli查询时,都会收到一个格式化错误,告诉我检查一下手册——尽管我不确定它到底出了什么问题。

$timeCheckEmp1 = "SELECT * FROM employee1 
   WHERE employee1.starttime BETWEEN $appointmentDateTime AND $endDateTime 
     OR $appointmentDateTime BETWEEN employee1.starttime AND employee1.endtime"    

$getResultEmp1 = mysqli_query($link, $timeCheckEmp1) or die(mysqli_error($link));

对于记录,我尝试将排队日期转换为字符串和日期时间值,但仍然得到错误。
php服务器给我的唯一帮助是它发生在 "AND ($endDateTime value) OR (appointmentDateTime value) BETWEEN employee1.starttime AND employee1.endtime" .
任何建议都是宝贵的,敬请指教。

k7fdbhmy

k7fdbhmy1#

我认为应该引用$appointmentdatetime和$enddatetime。

$timeCheckEmp1 = "SELECT * FROM employee1 WHERE employee1.starttime BETWEEN '$appointmentDateTime' AND '$endDateTime' OR '$appointmentDateTime' BETWEEN employee1.starttime AND employee1.endtime";
a2mppw5e

a2mppw5e2#

试试这个

SELECT * FROM employee1 
WHERE (employee1.starttime BETWEEN $appointmentDateTime AND $endDateTime )
OR ($appointmentDateTime BETWEEN employee1.starttime AND employee1.endtime)

相关问题