Integrity constraint violation: 1052 Column in where clause is ambiguous"

Posted: June 15, 2011 in Magento, Version 1.3.*, Version 1.4.*

For example in our custom module we have to add order_id in grid, if we search by order id in grid than such type of error occurs.

SQLSTATE[23000]: Integrity constraint violation: 1052 Column ‘Order_id’
in where clause is ambiguous

to resolve such error we can add ‘filter_index’=>’main_table.order_id’ in $this->addColumn() function


$this->addColumn('order_id', array(
'header' => Mage::helper('couponcode')->__('Order Id'),
'align' =>'left',
'index' => 'order_id',
'filter_index'=>'main_table.order_id', // This parameter helps to resolve above error
));

Thanks,
Bijal Bhavsar 🙂

Advertisements
Comments
  1. Harsh says:

    Hey Bijal ,

    Thanks, it is working like a charm , thanks a lot

    Thanks
    Harsh

  2. blush says:

    finally worked thanks..

  3. Mats-Ola says:

    I bow to you, master! Thank you very much!

  4. Khawar says:

    Great help, Thanks a lot

  5. Avtar Singh says:

    Great work. Thanks a lot.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s