RP
select * from
yarns
where exists (select * from colors
where yarns
.id
= colors
.yarn_id
and id
= '14')Ни чего не выведет т.к цвета с id 14 нет в базе.
select * from
yarns
where exists (select * from colors
where yarns
.id
= colors
.yarn_id
and id
= '1')выводит все цвета, а не только цвет с id 1. Что делаю не так?
Yarn::whereHas('colors', function($query) {
$query->where('id', '=', '1');
})
->get();
Я хочу получить пряжу и один ее цвет по id