php - "Error in your SQL syntax; check the manual that corresponds to your MySQL server version"PHP 时间比较问题

标签 php mysql

每次我尝试格式化 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" 周围。 .

任何建议都是建议。

最佳答案

试试这个

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

关于php - "Error in your SQL syntax; check the manual that corresponds to your MySQL server version"PHP 时间比较问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50790676/

相关文章:

php - Wordpress-使用insert_post时出现db_insert_error

php - 从 html 切换到 php 时消失的元素和奇怪的行为

javascript - 确认框中的密码 Javascript

mysql - 计算带有月份和其他条件的行数

php - 将 PDO 异常记录到 error_reporting 和 error_log

php - 编写 Laravel 查询 - 相关模型的计数为正

PHP sem_get 函数失败

MySQL - WHERE ATD 与 STD 的差值在负 10 分钟内

mysql - 未解析成员 'MySql.Data.MySqlClient.MySqlException,MySql.Data, Version=6.9.9.0,

mysql - 无法从动态 SQL 中将数据检索到变量中