How to convert mysql to laravel query builder [closed]

偶尔善良 提交于 2019-12-13 08:26:45

问题


Hi all i have this raw query in mysql i need to translate to laravel 5.4 query builder

select * from pages where (phase_id, type) in (select max(phase_id),type from pages where phase_id<=2 and actived=1 group by type) and actived=1

i don't know how to convert in query builder where clausule with 2 colum

any ideas?

Thx all


回答1:


$results = DB::select(
    select * from pages where (phase_id, type) 
    in (
        select max(phase_id), type 
        from pages 
        where phase_id <= 2 
        and actived = 1 
        group by type
    ) 
    and actived = 1
);


来源:https://stackoverflow.com/questions/42574418/how-to-convert-mysql-to-laravel-query-builder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!