project3 Posted February 26, 2008 Share Posted February 26, 2008 ok I have a select statement that works just fine. I want to alter it a little to add some to the where clause. in the db it selects by day of the week restaurants that match hours opened to the current time. but what i want to do is add more hours opened. as some restaurants will have three periods during the day when they are open like restaurant open close 9 11 1 3 5 10 now i have that set up in db. and can select the first result but i need a or statement and am unsure how to do a or in the following sql statemnt (at bottom of post). $thiscat in the following statement is the day of the week like $thiscat = catMonFrom $thiscat2 = catMonTo the other cats are catMonFrom2, catMonTo2, catMonFrom3, catMonTo3 catMon $Q = "select " . " c.catID, " . " catName, " . " catDesc, " . " catPhoto, " . " catPhotoWidth, " . " catPhotoHeight " . "from " . " ds_categories c " . "left join ds_language_categories l on " . " l.catID = c.catID " . "where " . " $thiscat <= '$tnow' and " . " $thiscat2 >= '$tnow' and " . " parentID = '$parentID' and " . " catHide != 'Y' and " . " l.langID = '$langID' " . " $ex " . "order by " . " catSort,catName " . "limit " . " $skip, " . $config->getValue('limit') . ""; Any help would be great. Quote Link to comment Share on other sites More sharing options...
rhodesa Posted February 26, 2008 Share Posted February 26, 2008 Try this: $Q = "select " . " c.catID, " . " catName, " . " catDesc, " . " catPhoto, " . " catPhotoWidth, " . " catPhotoHeight " . "from " . " ds_categories c " . "left join ds_language_categories l on " . " l.catID = c.catID " . "where " . " ('$tnow' BETWEEN catMonFrom AND catMonTo or " . " '$tnow' BETWEEN catMonFrom2 AND catMonTo2 or " . " '$tnow' BETWEEN catMonFrom3 AND catMonTo3) and " . " parentID = '$parentID' and " . " catHide != 'Y' and " . " l.langID = '$langID' " . " $ex " . "order by " . " catSort,catName " . "limit " . " $skip, " . $config->getValue('limit') . ""; Quote Link to comment Share on other sites More sharing options...
project3 Posted February 26, 2008 Author Share Posted February 26, 2008 Try this: $Q = "select " . " c.catID, " . " catName, " . " catDesc, " . " catPhoto, " . " catPhotoWidth, " . " catPhotoHeight " . "from " . " ds_categories c " . "left join ds_language_categories l on " . " l.catID = c.catID " . "where " . " ('$tnow' BETWEEN catMonFrom AND catMonTo or " . " '$tnow' BETWEEN catMonFrom2 AND catMonTo2 or " . " '$tnow' BETWEEN catMonFrom3 AND catMonTo3) and " . " parentID = '$parentID' and " . " catHide != 'Y' and " . " l.langID = '$langID' " . " $ex " . "order by " . " catSort,catName " . "limit " . " $skip, " . $config->getValue('limit') . ""; That worked great. I forgot about between that really helps out alot. Thank you again and do you know what happend to the topic solved button I don't see it anymore. Quote Link to comment 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.