0

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 .

6
  • Can you share the table structures? Commented Mar 23, 2017 at 5:29
  • sorry, bro, i am new for a stack . so I don't know how to share table structures Commented Mar 23, 2017 at 5:39
  • You can paste the CREATE codes of the tables here? Commented Mar 23, 2017 at 5:39
  • I pasted bro check it Commented Mar 23, 2017 at 5:42
  • What about the other table? BTW you duplicated your join statement. Commented Mar 23, 2017 at 5:44

2 Answers 2

1

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

2 Comments

i got same result bro
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.
0

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

Please check comment - i just replace leftjoin to join

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.