I use 2 databases in my Laravel project. One is MySQL and the other is SQL Server. My main database is MySQL.
I can use these databases individually, but if I want to join and use one of them in a query, I will face a problem.
This is my code
$list=DB::connection('mysql')->select('
SELECT
pp.mahsool_cod as planed_code,
SUM(pp.meghdar) as plan_quantity,
COUNT(*) as planed_count,
(SELECT SUM(tolid_reports.real_meghdar)
FROM tolid_reports WHERE tolid_reports.plan_tolid_date BETWEEN N\''.$head->date2.'\' and N\''.$head->date4.'\'
and tolid_reports.plan_cod= planed_code ) as tolid_quantity,
(N\''.DB::connection('sqlsrv')->select('select p.Name from farsi.LGS3.Part as p where p.Code =planed_code ').'\') as namee
FROM pr_planings AS pp
where pp.tolid_date BETWEEN N\''.$head->date2.'\' and N\''.$head->date4.'\' GROUP by pp.mahsool_cod
');
I can't to use the second database in the other database subquery