How to use "distinct on"?

Hi,

how can I use "distinct on", with the QueryBuilder?

Thanks,

Urkman

just call the distinct() method


$query = new Query;

$query->distinct(true)

    ->select('id, name')

    ->from('user')

    ->limit(10);

Hi,

thanks for your answer, but "distinct on" is different to a simple distinct.

See here:

Greetings,

Urkman

you should add this as a text:




Model::find()->select('distinct on (a) *')



1 Like

thanks, you save my day !