😁Laravel - Where Condition with Two Columns Example (ok)

https://www.itsolutionstuff.com/post/laravel-5-where-condition-with-two-columns-example-codeexample.html

Chú ý: 😒👌

$data = DB::table("items")
            ->whereColumn('created_at','updated_at')
            ->get();
print_r($data);
Được viết lại dưới dạng raw
$products = DB::table("products")
->where(DB::raw("created_at"),DB::raw("updated_at"))
->get();

Laravel - Where Condition with Two Columns Example

you can use wherecolumn() eloquent function in laravel 6, laravel 7, laravel 8 and laravel 9 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....

Last updated