对于我的应用程序,我正在使用Laravel并试图找出如何调整此查询,因为在开发中我使用MySQL但是为了测试,我使用SQLite。问题是我无法使用SQLite的DATEDIFF。是否有人建议我应该采取什么措施来检索标题长度最长的冠军?
return Champion::with('team')
->select(\DB::raw('DATEDIFF(IFNULL(DATE(champions.lost_on), '. Carbon::now()->toDateString().'), DATE(champions.won_on)) as length, team_id'))
->where('title_id', $title->id)
->orderBy('length', 'desc')
->groupBy('length', 'team_id')
->first();
答案 0 :(得分:0)
在SQLite中你可以使用
julianday('现在') - julianday(DateCreated)