Get values from 2 db tables and combine them

So working with queries…and I stumbled upon the next thing, as im getting results from 1 table which compairs data from a different table which goes good, but I need to add a matching value from the table that I use to compair it to.


 $slugs = $query->select('language, translation, cms_module_id')

                    ->from(['cbt'=>'cms_module_translation'])

                       ->leftJoin(['cb'=>'cms_module'], 'cb.id=cbt.cms_module_id')

                       ->where(['cb.is_deleted' => 0,

                                 'cb.is_enabled' => 1,

                                 'cbt.attribute' => 'slug'])

                       ->all();



The table cms_module contains a field called ‘route’, and I want to add this value to results (route is the same as the cms_module_id)

perhaps add alias to the fields you select


$slugs = $query->select('cb.language, cb.translation, cbt.cms_module_id')

            ->from('cms_module_translation cbt')

            ->leftJoin('cms_module cb', 'cb.id=cbt.cms_module_id')

            ->where([

                'cb.is_deleted' => 0,

                'cb.is_enabled' => 1,

                'cbt.attribute' => 'cb.slug'

            ])

            ->all();