Laravel Eloquent Query | Laravel Query Builder Where Exists Example

SELECT *
FROM `items`
WHERE EXISTS
(SELECT `items_city`.`id`
FROM `items_city`
WHERE items_city.item_id = items.id)
DB::table('items')
->whereExists(function ($query) {
$query->select("items_city.id")
->from('items_city')
->whereRaw('items_city.item_id = items.id');
})
->get();

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store