0

Is it possible to join two tables of different db connections (mysql and oracle in two different servers) based on condition?

I want to preform this query:

DB::connection('oracle')->table('SYSADM.PS_KS_COM_PERS_INF AS PRES')
->join(DB::connection('mysql')->table('students AS STU'), 
'PRES.NATIONAL_ID','=','STU.NationalID')
->where('PRES.STUDENT_STATUS', '=', 'Record Closed')
->where('STU.Batch', '=', $value->Batch)
->get(); // or count();

I created model of each table and connection,

but I couldn't join two models of two db connections

Learner
  • 611
  • 3
  • 12
  • 28

1 Answers1

1

Is it possible to join two tables of different db connections (mysql and oracle in two different servers)

No.

Oracle does offer heterogeneous access via its Database Gateway for ODBC feature. Once that feature is rigged up correctly, you'll be able to run queries like this.

 DB::connection('oracle')->table('some_oracle_table')->join('some_mysql_table@mysqlConnection') ...

Explaining how to rig that feature is waaaaaay beyond the scope of a Stack Overflow answer. Get your DBA to help.

Or, just read the data from your Oracle connection and your MySQL connection separately and correlate them in your program. That's the way to get the job done this year.

O. Jones
  • 103,626
  • 17
  • 118
  • 172