我在构建一个有说服力的查询时遇到了麻烦,我可以在其中重新创建这个sql命令:date_created列是datetime。
SELECT * FROM covidchecklist cc
LEFT JOIN patient_appointment pa ON cc.appointment_id = pa.appointment_id
LEFT JOIN users pat ON pa.user_id = pat.id
WHERE DATE_FORMAT(cc.date_created,'%Y-%m-%d') BETWEEN '2021-01-27' AND '2021-01-27'
字符串
我现在所拥有的:
CovidChecklist::leftJoin('patient_appointment', 'covidchecklist.appointment_id', '=', 'patient_appointment.appointment_id')
->leftJoin('users as patient', 'patient_appointment.user_id', '=', 'patient.id')
->whereRaw(' DATE_FORMAT(covidchecklist.date_created,"%Y-%m-%d") BETWEEN '.'$this->date_from'.' AND '.'$this->date_to'.' ')
->select(
*select stuff*
)
->get();
型
我使用whereRaw,因为我不能让它工作:
->whereBetween('covidchecklist.date_created', [$this->date_from, $this->date_to])
型
1条答案
按热度按时间s4n0splo1#
试试这个,伙计
字符串