Laravel Query Builder Where Exists Example

Laravel Query Builder Where Exists Example

In this post we will give you information about Laravel Query Builder Where Exists Example. Hear we will give you detail about Laravel Query Builder Where Exists ExampleAnd how to use it also give you demo for it if it is necessary.

you use sql where exists clause in laravel. whereExists through you can use sql where exists clause in your laravel project. It is very easy to use and you can easily undestand. You can give SELECT statment in where condition. you can see bellow example and you can learn how to use whereExists in your app.

SQL Query

SELECT *

FROM 'items'

WHERE EXISTS

(SELECT 'items_city'.'id'

FROM 'items_city'

WHERE items_city.item_id = items.id)

Using Laravel Query Builder

DB::table('items')

->whereExists(function ($query) {

$query->select("items_city.id")

->from('items_city')

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

})

->get();

Hope this code and post will helped you for implement Laravel Query Builder Where Exists Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

75  +    =  78

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US