Reputation: 2261
I need to get record only if subtraction of two fields is not zero.
$list = InspectionCertificate::where('amount' - 'billed_amount' != 0)
Thanks in advance.
Upvotes: 0
Views: 68
Reputation: 5582
Here is the sample code for that with Eloquent Model
$list = InspectionCertificate::whereRaw('(amount - billed_amount) > 0')->get();
You can use whereRaw
to pass raw query in Query Builder.
Upvotes: 2
Reputation: 14268
Sharing more info you will get a better answer, but here is a way using the query builder:
\DB::table('table_name')
->havingRaw('(column1 - column2) != 0')
->get();
Upvotes: 1
Reputation: 13237
Using Not Equal operator, you can able to do.
Sample query:
SELECT *
FROM TableName
WHERE (ColumnName1 - ColumnName2) != 0
Upvotes: 0