Laravel – Where Condition with Two Columns Example

Laravel – Where Condition with Two Columns Example

In this post we will give you information about Laravel – Where Condition with Two Columns Example. Hear we will give you detail about Laravel – Where Condition with Two Columns ExampleAnd how to use it also give you demo for it if it is necessary.

Laravel 5 introduce whereColumn() in Query Builder, that way we can compare two column like simple where condition. We sometimes require to check this type of condition.

In this example code, i have simple “items” table and i want to get only created_at and updated_at column should equals. So you can also check bellow laravel eloquent as bellow:

Example:

$data = DB::table("items")

->whereColumn('created_at','updated_at')

->get();

print_r($data);

Example 2:

Also see:Laravel where clause with date_format() example

$data = DB::table("items")

->whereColumn('created_at','>','updated_at')

->get();

print_r($data);

Hope this code and post will helped you for implement Laravel – Where Condition with Two Columns 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 *

22  +    =  30

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