SQL query for selecting events that occurs at a certain date and time
I figure my head around for the best possible query to get the actual event with ! query
This is what I have :
$date = date( 'Y-m-d' );
$time = date( 'Gi' );
dataso开发者_如何学编程urce : http://screencast.com/t/ODthUUpfR
$sql = "SELECT * FROM events WHERE startdate = '" . $date . "' AND stopdate >= '" . $date . "' ORDER BY stopdate ASC";
The problem I have is if the actual date is 2011-09-15 and the time is 600 (06:00)
The event would be still TeamA but with the above query it would return TeamB.
first, you should have these stored in two DATETIME fields... you are making it way more complicated by storing this in 4 fields.
Then you should do a query more like
WHERE $datetime BETWEEN start_datetime AND end_datetime
精彩评论