Showing results for 
Search instead for 
Did you mean: 

Column 'attribute_code' in order clause is ambiguous

Column 'attribute_code' in order clause is ambiguous


We are using Manage Customer Attribute Extension and customized this to fetch records from the eav_attribute table and we are getting the exception as:

$entityTypeId = $this->entityModel->setType(
        //Join eav attribute table
            ['eav_attribute' => $this->getTable('eav_attribute')],
            'eav_attribute.attribute_id = main_table.attribute_id'

When i am executing it getting below error as


Integrity constraint violation: 1052 Column 'attribute_code' in order clause is ambiguous, query was: SELECT `main_table`.*, `eav_attribute`.* FROM `vendor_mymarket_vendor_form_attribute` AS `main_table`
LEFT JOIN `eav_attribute` ON eav_attribute.attribute_id = main_table.attribute_id WHERE (eav_attribute.entity_type_id=9) ORDER BY attribute_code ASC


Can any one tell me solution for it?


Re: Column 'attribute_code' in order clause is ambiguous

Hi @KiranL,


Do you need to call all fields from both tables?

attribute_code is present on both tables and that's the problem.

I guess you have 2 options:


  1. Include only the neccesary fields from the second table.
  2. Override the order by and use something like main_table.attribute_code
If you've found one of my answers useful, please give "Kudos" or "Accept as Solution"