Laravel - Where Condition with Two Columns Example

About Us:

We are from free coder. We are a group of web developers who are passionate about web development. You can learn from us php, laravel, node js, vue js, react js and many other topic on web developement.
we are very happy to help you.
free coder

Today what you are going to learn:

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.

you can use wherecolumn() eloquent function in laravel 6, laravel 7 and laravel 8 application.

In this lesson 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);

Lesson 2:

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

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

->get();

print_r($data);

thank you very much for following up with me..

Recent Posts

Related Posts