I have 2 database Mysql
which can be ejemplo1
and ejemplo2
, one of which ejemplo1
I can not touch its structure at all so I was forced to create my own ejemplo2
, the issue is that the first ejemplo1
has data from many users which I need to bring, but there is no table to save the login data to the system (username and password), this table I am creating in ejemplo2
in this table I plan to create a field dni_user
which would relate to the field dni (Primary Key)
of ejemplo1
and be able to make the relevant relationships with laravel
and thus be able to recover the data of the user who login session.
I am not sure that this is possible to relate 2 tables of Base de datos
different.
Or in any case, just connect the 2 databases to my system and do a query
like for example:
SELECT
base1.*, base2.*
FROM
nombreBase1.nombreTabla base1
INNER JOIN
nombreBase2.nombreTabla base2
ON base1.id=base2.id
In which I include my 2 databases in the query
Is it possible to make this relationship through foreign codes? Or should I do it the other way?