Join WhatsApp ChannelJoin Now

Laravel Where null and Where not null eloquent query

In this article, we will show you Laravel Where null and Where not null eloquent query. This article will give you simple example of Laravel Where null and Where not null eloquent query. you will learn Laravel Where null and Where not null eloquent query. step by step explain Where null and Where not null eloquent query laravel.

we have following solution on SQL and Laravel query builder:

1) IS NULL = whereNull()

2) IS NOL NULL = whereNotNull()

Where Null Query

SQL Query:-

SELECT * FROM users

  WHERE name IS NULL;

Laravel Query:-

DB::table('users')

	->whereNull('name')

	->get();

Where Not Null Query

SQL Query:-

SELECT * FROM users

  WHERE name IS NOT NULL;

Laravel Query:-

DB::table('users')

	->whereNotNull('name')

	->get();

Recommended Posts