gpt4 book ai didi

php - Laravel Eloquent ORM 查询

转载 作者:太空宇宙 更新时间:2023-11-03 10:47:55 25 4
gpt4 key购买 nike

我一直在尝试将此 mysql 查询转换为 laravel 查询,但我无法弄清楚。

SELECT max(a.date) as max FROM table1 a, table2 b where
a.publishing_time<='2015-02-27 12:30:00' and a.Status='1' and
a.id=b.table1_id

表 1 字段是:-

 sl | date | publishing_time | status

表2字段是

 sl | table1_id | additional_fields

我卡在这上面了,请帮帮我

最佳答案

试试这个 Laravel 查询

DB::table('table1 as a')
->select(DB::raw('max(a.date) as max_date'))
->join('table 2 as b', 'a.id', '=', 'b.table1_id')
->where('a.publishing_time'<='2015-02-27 12:30:00')
->where(Status='1')
->get();

关于php - Laravel Eloquent ORM 查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28765612/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com