我的SQL数据库中有两个表。两者都有一个period_from列作为通用的日期格式。这两个表都有几个星期的数据,我已经连接了我的表,并且正在选择我需要的适当的列。
一切都很好,给了我正确的数据,但是一旦我添加了whereDate(),我就什么也得不到,一个空数组。我已经尝试了伪标准where(),也尝试了在我的表后面跟着我的列,例如:*.period_from,不确定为什么它在这里没有给我任何结果。
$from = Carbon::now()->subDays(14);
$to = Carbon::now();
$order = 'asc';
$data = DB::table('data_source_one as DGA')
->join('data_source_two as DLCA', 'DGA.created_at', '=', 'DLCA.created_at')
->where('event_action', 'Step 1 Loaded: (Loan Details)')
->select('event_count', 'sessions', 'leads', 'DGA.created_at', 'DGA.period_from', 'DGA.period_to')
->whereDate('DGA.period_from', '>=', $from)
->whereDate('DGA.period_to', '<=', $to)
->orderBy('DGA.created_at', $order)
->get();发布于 2021-01-26 00:28:38
你可以这样做:
$from = Carbon::now()->subDays(14);
$to = Carbon::now();
$order = 'asc';
$data = DB::table('data_source_one as DGA')
->join('data_source_two as DLCA', 'DGA.created_at', '=', 'DLCA.created_at')
->where('event_action', 'Step 1 Loaded: (Loan Details)')
->select('event_count', 'sessions', 'leads', 'DGA.created_at', 'DGA.period_from', 'DGA.period_to')
->where('DGA.period_from', '>=', $from)
->where('DGA.period_to', '<=', $to)
->orderBy('DGA.created_at', $order)
->get();https://stackoverflow.com/questions/65888510
复制相似问题