Answer the question
In order to leave comments, you need to log in
Is it possible in yii2 Active Record to get two fields with distinct on one of them?
Actually, you need to get a list of names of certain entities along with their id, but the distinct () method seems to work only if you select one column of data, do you really need to write bare sql?
Answer the question
In order to leave comments, you need to log in
Perhaps I misunderstood the question, but how do you imagine it? If you make a query like SELECT DISTINCT some_field, id FROM some_table; the database will return non-repeating combinations of some_field and id fields. And since id you most likely have a primary key, then it will be unique for each record, which means that the situation when there are several records in some_table for which some_field and id are pairwise equal is impossible in principle. Show the request itself which you want to receive as a result?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question