-1

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

0

1 Answer 1

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
);
Sign up to request clarification or add additional context in comments.

2 Comments

Thx @EddyTheDove ;) exists another way using ->whare() or whareIn() method of query builder?
if you have an array of IDs, yes you can use whereIn. But it doesnt take SQL like that. You must pass it an array.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.