i have two tables 'users' and 'projects'
Table users
-----------------------------------
user_id | name | email | password |
-----------------------------------
1 |name1 |email1 | password1|
-----------------------------------
2 |name2 |email2 | password2|
Table projects
project_id |user_id | name |
--------------------------------------
1 | 1 | project_name1 |
-----------------------------------
2 | 1 | project_name2 |
There is no relation between these two tables but user_id in projects are the id from user table.
Normal Query
SELECT a.user_id,a.name AS username,b.name AS project_name FROM users a LEFT JOIN projects b ON a.user_id=b.user_id;
I want the same query execution in laravel eloquent.
Have searched in google got some idea about "with" function but not able to get the output.
Thanks.
DB::raw
? – Sulthan Allaudeen