I want to write this MySql Query in Laravel Controller

Issue

SELECT user_matches.*
FROM users u
JOIN user_matches
    ON u.id = user_matches.user_id AND 
        FIND_IN_SET(
            user_matches.to_user_id,
            (
                SELECT GROUP_CONCAT(users.id) FROM `users`
            )
        );

Solution

Do it with

\Illuminate\Support\Facades\DB::select('') 

to write you raw query .

Answered By – Ehsan Tavakoli

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published