- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-11-2018
11:55 PM
06-11-2018
11:55 PM
Column 'attribute_code' in order clause is ambiguous
Hi,
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( \Magento\Customer\Model\Customer::ENTITY )->getTypeId(); parent::_initSelect(); //Join eav attribute table $this->getSelect()->joinLeft( ['eav_attribute' => $this->getTable('eav_attribute')], 'eav_attribute.attribute_id = main_table.attribute_id' ); $this->getSelect()->where('eav_attribute.entity_type_id=?',$entityTypeId);
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?
Labels:
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2018
07:38 PM
06-18-2018
07:38 PM
Re: Column 'attribute_code' in order clause is ambiguous
Hi @Kiran,
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:
- Include only the neccesary fields from the second table.
- Override the order by and use something like main_table.attribute_code