Magento, Magento 2, Magento Admin, Magento basic, Magento Database, Magento2.2, MySql

SQLSTATE[23000]: Integrity constraint violation: 1052 Column ‘id’ in where clause is ambiguous – Magento 2

Some time’s when you integrate your custom admin form in magento 2 there is a chance’s to get the Error message as like below,
SQLSTATE[23000]: Integrity constraint violation: 1052 Column ‘id’
One of the reason to get this issue is same column name may declard with more than one tables. When you use multiple table with Join query we may get this issue. To resolve this issue we have to specify the tableName from the form or Grid file.
Ex:
‘filter_index’ => ‘main_table.id’,
Here id is used multiple tables. When you join the the tables will get this issue.
To resolve use filter_index & specify the table name. Here main_table am using the alias.

 

 

Leave a Reply