Jump to content

between statement


project3

Recommended Posts

Im using the between statement to find open restaurants in a db. the thing is it doesn't return result when the first number is equal

 

so say restaurants open time is 5:00 to 10:00

 

if i say the current time is 5:00 I won't return a result until its 5:01.

so is there a way i can say between and equal im not sure.

I have my coded below.

$query = "select * "
      . "from "
      . "ds_categories "
      . "where "
      . "  ('$tnow'  BETWEEN $thiscat AND $thiscat2 OR "
      . "   '$tnow'  BETWEEN $thiscat3 AND $thiscat4 OR "
      . "   '$tnow'  BETWEEN $thiscat5 AND $thiscat6) and "
      . "  catID = '$v_c' AND "
      . "  catHide != 'Y' "
      . "order by catSort "     
      . "";

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/98360-between-statement/
Share on other sites

use more OR clauses

 

$query = "select * "
      . "from "
      . "ds_categories "
      . "where "
      . "  ('$tnow'  BETWEEN $thiscat AND $thiscat2 OR "
      . "   '$tnow'  BETWEEN $thiscat3 AND $thiscat4 OR "
      . "   '$tnow'  BETWEEN $thiscat5 AND $thiscat6) OR "
      . "   '$tnow'  =  '$thiscat' OR "
      . "   '$tnow'  =  '$thiscat3' OR "
      . "   '$tnow'  =  '$thiscat5' and "
      . "  catID = '$v_c' AND "
      . "  catHide != 'Y' "
      . "order by catSort "     
      . "";

Link to comment
https://forums.phpfreaks.com/topic/98360-between-statement/#findComment-503356
Share on other sites

use more OR clauses

 

$query = "select * "
      . "from "
      . "ds_categories "
      . "where "
      . "  ('$tnow'  BETWEEN $thiscat AND $thiscat2 OR "
      . "   '$tnow'  BETWEEN $thiscat3 AND $thiscat4 OR "
      . "   '$tnow'  BETWEEN $thiscat5 AND $thiscat6) OR "
      . "   '$tnow'  =  '$thiscat' OR "
      . "   '$tnow'  =  '$thiscat3' OR "
      . "   '$tnow'  =  '$thiscat5' and "
      . "  catID = '$v_c' AND "
      . "  catHide != 'Y' "
      . "order by catSort "     
      . "";

 

Awesome great idea!

Link to comment
https://forums.phpfreaks.com/topic/98360-between-statement/#findComment-503367
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.