Today now in this post i will show you How to use Where Condition with Two Columns in Laravel ? We know in Laravel introduce whereColumn() in the Query Builder, on that way we can compare between two column as like simple where condition. So sometimes We may need to check this type of condition.
So we can use wherecolumn() eloquent function in any version of laravel 6, laravel 7 and laravel 8 application.
Now in this example , i have a simple table as name “items” and i want to get the only created_at and updated_at column should be equals. So we can also check the bellow laravel eloquent as like as bellow:
$data = DB::table("items") ->whereColumn('created_at','updated_at') ->get(); print_r($data);
$data = DB::table("items") ->whereColumn('created_at','>','updated_at') ->get(); print_r($data);
Thanks for read. I hope it help you. For more you can follow us on facebook