Home > Net >  How to join csv data with another table in laravel
How to join csv data with another table in laravel

Time:12-14

I am using laravel framework to develop API's i am facing one scenario i want to join table1 csv data to table2 primary id, after some research i found some answers in stack overflow but it's throwing an following error

SQLSTATE[42S22]: Column not found: 1054 Unknown column '' in 'on clause' 

Table1

id              cat_id
1              2,3,4

Table2

id              name
  1             test1
  2             test2
  3             test4

can anyone help me to acheive this join ?

CodePudding user response:

without seeing query can't able to assume the scenario.for my case i will fix with the following way, Try the following one and let me know if it works..

Table1::where('some conditions')
 ->leftJoin('books',function($join){
   $join->whereRaw(DB::raw("FIND_IN_SET(books.id,Table1.cat_id)"));
 })
  • Related