Laravel SQL查询午夜未显示
我正在制作计划显示系统,并显示渡轮的时间表。我的问题是,如果我不按顺序放置午夜时间,请查询跳过午夜的时间并显示早晨的
例子: -
如果我以这样的方式放置数据
- 1:30 AM
- 6:30 AM
- 7:30 AM,
那么Times可以正确显示,但是如果不是在
- 6:30 AM
- 7:30 AM
- 1:30 AM
上的命令,那么查询会跳过1:30 AM,直接直接进入6:30进行显示。
这是我的Laravel SQL查询: - 如果出发时间大于当前时间,则显示下一个可用的一个
DB::table('ferries')->groupBy('ferry_name')
->whereTime('departure_time', '>', Carbon::now()->toTimeString())
->whereIn('schedule_type', ['Weekday'])
->where('terminal_name', $terminal_name)->get()->all();
I am making a schedule display system and it shows the schedules of ferries. my problem is if I dont put midnight time in order then query skips midnight time and displays morning instead
EXAMPLE:-
if i put data in order like this
- 1:30 am
- 6:30 am
- 7:30 am
then the times show correctly, but if its not in order
- 6:30 am
- 7:30 am
- 1:30 am
then the query skips the 1:30 am and goes straight to 6:30 to display.
Here is my laravel SQL Query:- if departure time is greater than current time then show the next available one
DB::table('ferries')->groupBy('ferry_name')
->whereTime('departure_time', '>', Carbon::now()->toTimeString())
->whereIn('schedule_type', ['Weekday'])
->where('terminal_name', $terminal_name)->get()->all();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
结果集本质上是未排序的,您需要添加排序顺序
这将按升序排序,请参阅 手册
Resukltsets are by nature unsorted yo you need to add a sorting order
This would sort ascending see manual
使用了unique()而不是groupby(),然后订单不确定为什么。
Used unique() instead of groupBy() then the orderBy worked not sure why.