Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to join csv data with another table in laravel

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

id              name
  1             test1
  2             test2
  3             test4

can anyone help me to acheive this join ?

>Solution :

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)"));
 })
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading