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, laravel 8, laravel 9 and laravel 10 application.
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:
Read Also: Laravel Where Clause with date_format() Example
$data = DB::table("items")
->whereColumn('created_at','>','updated_at')
->get();
print_r($data);
I hope it can help you….