Laravel Eloquent where null and where not null query

Laravel Eloquent where null and where not null query

How we can find the NULL and Not NULL records using the Laravel. Laravel provides a whereNull for finding the NULL records and whereNotNull for finding the NOT NULL records. Today, we are going to learn both methods with example.

Laravel Eloquent where null

1 ) whereNull

First of all, We are going to learn whereNull method for finding the NULL records. Let’s see how we can find the NULL records from database using the Laravel Eloquent like.

DB::table('company')
    ->whereNull('description')
    ->get();

/*
* My SQL Query
*/
select * from comapny where description IS NULL

2 ) whereNotNull

Let’s see how we can find the NOT NULL records form the database using the Laravel with example.

DB::table('company')
  ->whereNotNull('description')
  ->get();
/*
* My SQL Query
*/
select * from comapny where description IS NOT NULL

I hope this article useful for you. Please let us know if anything was missing or wrong by comment.

Related Posts

  1. Email unique validation in Laravel ignore id on update
  2. WordPress Button Shortcode – Add button to WordPress editor
  3. WordPress shortcode – How to create shortcode in WordPress
  4. WordPress change URL in database using MySQL Query
  5. PHP remove HTML tags from string using strip_tags
  6. Enable shortcodes in widget WordPress
  7. PHP remove non-empty directory programmatically
  8. PHP File upload step by step with example
  9. Laravel 6 integrate AdminLte admin theme jeroennoten
  10. WooCommerce add product to cart with custom price

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search Posts

Subscribe To Newsletter

Get Early Access To New Articles, Plugins, Discount Codes And Quickly Brief Updates about tips and tricks

Join 308 other subscribers