0

I have tables when there are 2 columns. The first column is the start time work shop. The second column is the hour of the completion of the work shop.

Examples:

id | start | stop
1  |    10 | 18
2  |     8 | 20
3  |    11 | 21

I need a list of stores that are now working.

Now hour = 10
start >= '".$now_hour."' and stop <= '".$now_hour."'

I see only shop id=1, but shop id=2 also should be listed.

4

2 回答 2

3

逻辑不正确?

`start` <= '".$now_hour."' and `stop` >= '".$now_hour."'
于 2014-04-28T09:18:44.887 回答
1

您可以使用between带有您的价值的子句nowHour

where ? between start and stop

?是价值的占位符nowHour
使用脚本语言中的准备好的语句来绑定占位符。

于 2014-04-28T09:25:21.987 回答