T
T
Tvis20102017-04-29 01:13:04
MySQL
Tvis2010, 2017-04-29 01:13:04

How to merge 2 bases into one based on several conditions?

The bottom line is that I need to Assign the data of one database to the data of another ..
There is a dep database, it has a user_id. It is
necessary to extract the data about the user dep.user_id from the users database and actually combine them.
But so that they do not overwrite each other's values, here is a working example:

$hdata = \DB::table('dep')
     ->join('users', 'dep.user_id', '=', 'users.idshka')
     ->get();

But it overwrites the data from dep with the data from users.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DevMan, 2017-04-29
@Tvis2010

1. not databases, but tables
2. learn what aliases are in sql
3. read the documentation on the framework query builder
4. stackoverflow.com/questions/37650183/laravel-5-1-e...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question