Magento Forum

   
Mysql ambiguous Error in admin grid filter in magneto or “SQLSTATE[23000]: Integrity constraint violation: 1052 Column ‘status’ in where clause is am
 
pradeep_kumar67
Sr. Member
 
Avatar
Total Posts:  160
Joined:  2010-06-24
Bangalore
 

Hi,

if you have same name of column in collection and in grid when you filter it you will get one my sql error

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

at that time in grid _prepareColumns() funtion

add filter_index option in fields

that is

$this->addColumn("status", array(
                
"header" => Mage::helper("custompromotion")->__("Status"),
                
"align" =>"left",
                
"index" => "status",
                
"filter_index" => "main_table.status",
                
'type'      =>  'options',
                
'options'   =>  $option,
                ));
“filter_index” =>; “main_table.status”,
main_table.status==> “main_table” is alias of you table and “status” is column

this issue will happen when you join 2 tables and have same field name

 
Magento Community Magento Community
Magento Community
Magento Community
 
dgiouzelis
Jr. Member
 
Total Posts:  10
Joined:  2008-08-04
 

Hello, and what is the solution you sugesting?
i am not getting the point..
can you pls specify it ?

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top