Laravel query where col1 != col2



我有DB表'项目'与列'col1', 'col2'和其他。我需要laravel ORM的结果项。条件:所有col1 != col2

的项
where col1 != col2

您可以使用LaravelwhereColumn。它用于比较两个列。你可以在这里查看文档https://laravel.com/docs/8.x/queries

DB::table('table_name')->whereColumn('col1', '<>', 'col2')->get();

最新更新