I'm trying to left join two tables in laravel. after joining got all second table value is empty but data exist in a database .
-
Can you share the table structures?Taha Paksu– Taha Paksu2017-03-23 05:29:13 +00:00Commented Mar 23, 2017 at 5:29
-
sorry, bro, i am new for a stack . so I don't know how to share table structuresSaran– Saran2017-03-23 05:39:14 +00:00Commented Mar 23, 2017 at 5:39
-
You can paste the CREATE codes of the tables here?Taha Paksu– Taha Paksu2017-03-23 05:39:55 +00:00Commented Mar 23, 2017 at 5:39
-
I pasted bro check itSaran– Saran2017-03-23 05:42:59 +00:00Commented Mar 23, 2017 at 5:42
-
What about the other table? BTW you duplicated your join statement.Taha Paksu– Taha Paksu2017-03-23 05:44:06 +00:00Commented Mar 23, 2017 at 5:44
|
Show 1 more comment
2 Answers
Can you try this:
$contacts = DB::table('C_Contacts')
->leftJoin('C_Contact_Category_Map', 'C_Contacts.contact_id', '=', 'C_Contact_Category_Map.contact_id')
->get();
2 Comments
Saran
i got same result bro
Taha Paksu
Then check your database because it might really be empty or you are joining the wrong table, or you might not be saving the contact_id's on the category map table etc.
Can You try this
$contacts = DB::table('C_Contacts')
->join('C_Contact_Category_Map', 'C_Contacts.contact_id', '=', 'C_Contact_Category_Map.contact_id')
->get();
1 Comment
Tarang M Patel
Please check comment - i just replace leftjoin to join