我正在进行搜索,搜索工作正常,查询的唯一部分是给我的问题是什么时候 比较DATE((LiveTrip.TripDate)> = DATE(?))。
它没有给我一个错误,它只是没有带回我使用heidi sql测试此查询的任何东西,它的工作原理。日期以YYYY-MM-DD格式发布。针对比较的字段在db中具有日期数据类型。有什么建议吗?
$Limit = $_POST['limit'];
$Offset = $_POST['offset'];
$TripType = $_POST['TripType'];
$datesearch = $_POST['datesearch'];
$Departure = "%{$_POST['Departure']}%";
$Destination= "%{$_POST['Destination']}%";
$stmt = $conn->prepare("SELECT
UsersMain.Id,
UsersMain.Name,
UsersMain.Surname,
LiveTrip.Id,
LiveTrip.DepstreetAddress,
LiveTrip.DepSubTown,
LiveTrip.DestStreetAddress,
LiveTrip.DestSubTown,
LiveTrip.SeatsAvailable,
LiveTrip.TripDate,
LiveTrip.TripTime,
LiveTrip.Contribution,
LiveTrip.Comments
FROM
LiveTrip
INNER JOIN UsersMain ON UsersMain.Id = LiveTrip.UserId
WHERE
LiveTrip.DepSubTown like ?
AND
LiveTrip.DestSubTown like ?
AND LiveTrip.TripStatus =1 AND DATE((LiveTrip.TripDate) >= DATE(?)) AND TripType=? LIMIT ? OFFSET?");
$stmt->bind_param("ssssss",$Departure, $Destination, $TripType,$datesearch, $Limit, $Offset);
/* execute query */
$stmt->execute();
/* Store the result (to get properties) */
$stmt->store_result();
/* Get the number of rows */
$num_of_rows = $stmt->num_rows;
$stmt->bind_result($id,$Name,$Surname,$Tid,$DepstreetAddress,$DepSubTown,$DestStreetAddress,$DestSubTown,$Seats,$TripDate,$TripTime,$Contribution,$Comment);