I'm trying to get a SQL query to work to check for dates before a given time. It is intended to prevent reservation conflicts with this room booking website I am working on. Some of the syntax appears to be wrong, but I'm not quite sure what the correct syntax is. This is my query:
$periodcheck="SELECT * FROM Reservations WHERE roomID='$roomID' OR
roomID=4 AND reservationDate<$datestamp ORDER BY reservationID DESC";
The roomID corresponds to a particular room, and the reservationDate is a date type in the database. The datestamp is a timestamp. Any ideas of what isn't right here?
if $datestamp is coming from an external (such as a programming language) or even just a string, as most likely since you're not binding your parameters, you'll need to use something date_format, or to_date.