A
A
Artem2020-10-27 13:34:26
Laravel
Artem, 2020-10-27 13:34:26

How to make a request in laravel?

Why does the on() method turn the alias dt into prefix_dt?
The muscle naturally swears at the lack of prefix_dt.idfd:
Unknown column 'prefix_dt.idfd' in 'on clause'

->leftJoin(DB::raw("(SELECT MAX(sdp.saledate) AS saledate, sdp.branch AS idfd FROM prefix_params sdp GROUP BY sdp.branch) AS dt"),
                function($join)
                {
                    $join->on('dt.idfd', "=", 'branches.id');
                });

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem, 2020-10-27
@artemky

it turns out that you need to wrap the field in DB:: raw ()
$join->on(DB::raw('dt.idfd'), "=", 'branches.id');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question