Level 2
I dont think subquerying is necessary here. You could simply make raw sql:
DB::select('select * from campaign where campaing.current < campaign.max');*/
or
Campaign::->whereRaw('table1.field1 < table1.field2')
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi, i have model tables like this:
id|name|current|max
1 | campaign 1 | 1 | 10
2 | campaign 2 | 5 | 15
3 | campaign 3 | 10 | 10
4 | campaign 4 | 10 | 20
5 | campaign 5 | 20 | 20
i like to select all campaign that the current is not more than max
Campaign::where('current', '<', 'max')->get();
how to do that with eloquent, i need some light:
Please or to participate in this conversation.