Laravel WhereNotIn Query Example (ok)
https://www.itsolutionstuff.com/post/laravel-wherenotin-query-exampleexample.html
Đọc thêm: Laravel - whereIn and whereNotIn with subquery example using query builder
Laravel WhereNotIn Query Example
By Hardik Savani January 6, 2020 Category : LaravelPauseUnmuteLoaded: 2.33%FullscreenThis article will provide you example of where not in laravel query builder. we will write where not in query in laravel eloquent. it is very simple example of wherenotin in laravel application. you can see bellow where not in in laravel eloquent.
you can simple use wherenotin eloquent method in laravel 6, laravel 7, laravel 8 and laravel 9.
If you need to use sql wherenotin query in laravel then you can use with array. Laravel provide wherenotin() to use sql wherenotin query. in wherenotin() we just need to pass two argument one is column name and another if array of ids or anything that you want.
You can see bellow syntax on wherenotin query in laravel:
Now i will give you three example of how to use wherenotin query in laravel application. So let's see those example how it works.
Example 1:
SQL Query:
Laravel Query:
Example 2:
Here is another example of wherenotin query. You can work with comma separated string value. you can work as like bellow:
Example 3:
Read Also: Laravel Wherein Query Example
I hope it can help you...
As you know laravel is very popular php framework in today. So every point will be require for database related and that important. In this post i would like to share with you how to use subquery with whereIn and whereNotIn clause from scratch.
We may sometimes require to use select query with where in or where not in clause in laravel 6, laravel 7, laravel 8 and laravel 9. we can simply make query using MySQL. But we don't know how to use it on laravel query builder. However, In this example we will learn how to convert mysql query into laravel query builder of wherein with subquery. This example is from scratch, so i will give you first mysql query and then we will convert it into laravel query builder.
In this example i have to tables as listed bellow:
1) users
2) invite_users
Where In Query
In first query, basically we require users that only in invite_users table. we can normally retrieve using bellow sql query:
SQL Query:
As bellow we can convert for laravel application.
Laravel Query:
Where Not In Query
In second query, basically we require users that not in invite_users table. we can normally retrieve using bellow sql query:
SQL Query:
As bellow we can convert for laravel application.
Laravel Query:
Read Also: Laravel - How to make subquery in select statement?
I hope it can help you....
Last updated