0

This is my code:

$statusTable = $dbHelper->getTableName("mp_os_statuses");

        $this
            ->getSelect()
            ->joinInner(array('status'=>$statusTable), "status.value = main_table.status")
            ->order("status.position ASC")
            ;

I actived the sql logs I executed the latest query and I saw that I have 2 entity_ids with the same value. As a result I get the error message:

 with the same id "27" already exist

So I search over the internet that I should add a distinct statement to my query. How can I do that ? thx

UPDATE This is the query from the log:

SELECT `main_table`.*, `status`.* FROM `mp_os_state_status` AS `main_table`
 INNER JOIN `mp_os_statuses` AS `status` ON status.value = main_table.status WHERE (main_table.state = 'payment_review') ORDER BY `status`.`position` ASC
1

I should added the group by condition, not distinct:

        $this
            ->getSelect()
            ->joinLeft(array('status'=>$statusTable), "status.value = main_table.status")
            ->group('entity_id')
            ->order("status.position ASC")
            ;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.