franky stein
franky stein

Reputation: 37

Laravel Eloquent Equivalent for MYSQL DISTINCT query multiple columns

Is there an equivalent query for this in eloquent?

 SELECT DISTINCT agent_code,ord_amount FROM orders

Upvotes: 0

Views: 4578

Answers (2)

Hedayatullah Sarwary
Hedayatullah Sarwary

Reputation: 2834

Try to use this eloquent query:

$orders = Order::select('agent_code', 'ord_amount')->distinct()->orderBy('agent_code')->get();

Upvotes: 0

P. K. Tharindu
P. K. Tharindu

Reputation: 2730

Try something like this:

Order::select('agent_code', 'ord_amount')->distinct()->get();

Upvotes: 1

Related Questions