L
L
Lavrov952018-01-17 19:50:20
Zend Framework
Lavrov95, 2018-01-17 19:50:20

How to join same table?

Statement could not be executed (42000 - 1066 - Not unique table/alias: 'media')

$select->join(
            DbTables::TBL_MEDIA,
            DbTables::TBL_MEDIA . '.id = ' . $this->getTable() . '.media',
            [
                'logo_path' => 'media_path'
            ],
            Select::JOIN_LEFT
        );

        $select->join(
            DbTables::TBL_MEDIA,
            DbTables::TBL_MEDIA . '.id = ' . DbTables::TBL_REL_ANNOUNCEMENT_MEDIA . '.media_id',
            [
                'announcement_media_path' => 'media_path'
            ],
            Select::JOIN_LEFT
        );

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ivankomolin, 2018-01-17
@ivankomolin

Specify different aliases
, eg m1 and m2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question