G
G
GrimJack2017-07-19 18:31:42
MySQL
GrimJack, 2017-07-19 18:31:42

Is it possible to make such a join request?

Previously, the data was formed in the following way:

UserData::where('user_id', '=', Auth::user()->id)
            ->join(DB::raw('element as e'), 'e.field_name', '=', 'users_data.field_name')
            ->join(DB::raw('section as s'), 's.section_id', '=', 'e.section_id')
            ->select([
                'users_data.field_name',
                'users_data.data',
                's.permission_group',
                'e.element_label',
                's.section_id',
            ])
            ->get()

That is, we got all the user data from the table and added data from the section and element table to them
. Now we need to get data from element, add section and users_data to them.
In the first case, in section and element there is always data for users_data
However, in the new logic, there may not be data in users_data, so where there is no data 'users_data.field_name' and 'users_data.data' we should just leave it empty
. Actually, can it exist? such a join request?
PS It is not possible to check now, that's why I'm asking here

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2017-07-19
@dimonchik2013

sql%2Bjoins%2Bguide%2Band%2Bsyntax.jpg

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question