union and limit issue

Short version

I union 2 queries and the LIMIT is applied within the first query. I want it to be applied at the outer most level e.g. LIMIT should be applied after 2 queries union

Full description is described at Issue 11097 (https://github.com/yiisoft/yii2/issues/11097).

Klimov-paul directed me to Issue 7992 (https://github.com/yiisoft/yii2/issues/7992)

I’ve read them over and over and still can not come to a good conclusion.

Is this a limitation of yii2 or I do things wrong ?

Thank you

can anyone help pls ?

As mdmnir suggests, you can try something like this:

$query1 = (new \yii\db\Query())

    ->select("id, category_id AS type, name")


$query2 = (new \yii\db\Query())

    ->select('id, type, name')


$maiQuery = (new yii\db\Query())