SQL query with multiple database and different tables in Laravel
DB::select("SELECT db1.employees.name AS employee_name, db2.companies.name as company_name
FROM db1.employees employees
JOIN db2.companies companies ON companies.code = employees.company_code
WHERE companies.country = 'Bangladesh' ");
Note: Both database users and passwords have to be the same.
Comments
Post a Comment