S
S
Sergey Bard2018-02-07 17:05:31
Yii
Sergey Bard, 2018-02-07 17:05:31

How to combine multiple requests?

Hello. There is such a request

Description::find()->select(['LEFT(`name`, 1) AS name', 'LEFT(`name_en`, 1) AS name_en'])->distinct()->all()

but distinct does not work here and stupidly throws out everything that is in the database.
1) how to make it possible to make a selection as I indicated, i.e. take the first letter without duplication in two columns at once, it would be great if it is possible to make the selection case -insensitive
2) I put the first column in name, the second in name_en, if I make the second one also put in name
Description::find()->select(['LEFT(`name`, 1) AS name', 'LEFT(`name_en`, 1) AS name'])->distinct()->all()

then it overwrites the first one, can you somehow make a selection in one variable?
ps made two requests,
Description::find()->select(['LEFT(`name`, 1) AS name'])->distinct()->all()
Description::find()->select(['LEFT(`name_en`, 1) AS name_en'])->distinct()->all()

and put it in one array, so everything works, but is it still possible to somehow put everything in one request?)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question