Laravel Query Builder Where Exists Example

By Hardik Savani November 5, 2023 Category : PHP Laravel MySql

The database query builder in Laravel provides a simple, intuitive interface for generating and performing database queries. It works with every one of Laravel’s supported database systems and may be used to conduct most operations on the database in your application.

Today, in this post, we will show you an example of a laravel query builder where exists. When using the where exists clause in SQL Query in Laravel. And we can utilize SQL where exists clause in our laravel project thanks to whereExists.

As a result, it is incredibly simple to use and learn. In the where condition, we can use the SELECT query.

We can learn how to utilize whereExists in our application by looking at the example code below.

SQL Query:


FROM `items`


(SELECT `items_city`.`id`

FROM `items_city`

WHERE items_city.item_id =

Using Laravel Query Builder:


->whereExists(function ($query) {



->whereRaw('items_city.item_id =');



I hope it can help you..

Tags :