I have this code:
$abcd= DB::table('control')
->leftJoin('proces', 'proces.id_control', '=', 'control.id_control')
->select('control.id_risk', DB::raw("group_concat(proces.id_procedur) as prc"))
->where('control.id_theme', '=', $id)
->whereExists(function ($query) {
$query->select('id_control')
->from('proces') ->where('control.id_control','proces.id_control');
})
->groupBy('control.id_risk')
->get();
This query work perfectly, when i wrote it in phpmyadmin, but when I try to execute it in app query return empty array. Where is problem
UPDATE
After i check how looks query from laravel there is one wrong
select `control`.`id_risk`, group_concat(proces.id_procedur) as prc from `control` left join `proces` on `proces`.`id_control` = `control`.`id_control` where `control`.`id_theme` = ? and exists (select `id_control` from `proces` where `control`.`id_control` = ?) group by `control`.`id_control`
First question mark is corrent beacue this $id(by the way variable is passing good value) but the second question mark should not be there.