r00ttap Posted February 20, 2009 Share Posted February 20, 2009 My problem is that I'm trying to make my code as efficient as possible by pulling only what I need from the database. I will try and draw this out so it will make some sense to you. My current database would be: +--------------+--------------+ | end_time | date +--------------+--------------+ | 15:30:00 | 2009-02-02 +--------------+--------------+ I need something posted UNTIL the end_time is up on that specific date. My query looks somethign like this: $campus_name = mysql_query("SELECT * FROM table WHERE campus = 'campus_name' AND date >= CURDATE() ORDER by date, time") or die(mysql_error()); Of course this will keep something posted until the date changes but I really need the text to disappear after the time is over. Is this something the SQL can't handle and that I may just have to narrow it down even more with PHP? Quote Link to comment https://forums.phpfreaks.com/topic/146153-solved-slimming-down-results-with-sql-query/ Share on other sites More sharing options...
r00ttap Posted February 20, 2009 Author Share Posted February 20, 2009 I figured it out. $campus_name = mysql_query("SELECT * FROM table WHERE campus = 'campus_name' AND CONCAT(date,' ',time) >= NOW() ORDER by date, time") or die(mysql_error()); Which simply concatenates the date and time to YYYY-MM-DD HH:MM:SS which is exactly what NOW() returns. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/146153-solved-slimming-down-results-with-sql-query/#findComment-767327 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.