This is really a MeekroDB exclusive issue, just trying to wrap my head around Left_Join.
I have 2 Tables: comp_checklis
t and comp_checklist_items
I want to get all the rows from comp_checklist
where the user Id matches and this worked fine:
DB::query("SELECT * FROM comp_checklist WHERE user_id = %i", $user_id );
Now I wand to get that same query ( all the rows from comp_checklist
where the user Id matches ) and add any comp_checklist_items rows where checklist_id
matches in both tables (checklist_id
is the primary key in the comp_checklist
table). I used below but just get false
DB::query("SELECT * FROM comp_checklist WHERE user_id = %i LEFT JOIN comp_checklist_items on checklist_id = comp_checklist.checklist_id", $user_id );
JOIN should come before WHERE, and all columns should have the table name or you will get an error: