{"id":3496,"date":"2014-03-27T04:50:36","date_gmt":"2014-03-27T04:50:36","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/27\/sqlstate42s22-column-not-found-1054-unknown-column-main_table-sfo-customer_email-in-where-clause-closed-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:50:21","modified_gmt":"2022-08-30T15:50:21","slug":"sqlstate42s22-column-not-found-1054-unknown-column-main_table-sfo-customer_email-in-where-clause-closed-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/27\/sqlstate42s22-column-not-found-1054-unknown-column-main_table-sfo-customer_email-in-where-clause-closed-collection-of-common-programming-errors\/","title":{"rendered":"SQLSTATE[42S22]: Column not found: 1054 Unknown column &#39;main_table.sfo.customer_email&#39; in &#39;where clause&#39; [closed]-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/402aa88a31b6f8391908d8a6f8a187a7?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nThe Smart Dude<\/p>\n<p>Help. I have been struggling with this error for a few days now and have yet to find an answer. I am trying to add a few columns to the orders grid in Magento 1.6.2 I followed the instructions from: [http:\/\/www.milessebesta.com\/web-design\/magento-customize-backend-order-grid-to-have-sku-e-mail-address-and-phone-number\/][1]<\/p>\n<p>Here is the error message:<\/p>\n<blockquote>\n<p>SQLSTATE[42S22]: Column not found: 1054 Unknown column &#8216;main_table.sfo.customer_email&#8217; in &#8216;where clause&#8217;<\/p>\n<\/blockquote>\n<p>Here is my code:<\/p>\n<pre><code>protected function _getCollectionClass()\n{\n    return 'sales\/order_collection';\n}\n\nprotected function _prepareCollection()\n{\n\n    $collection-&gt;getSelect()-&gt;group('main_table.entity_id');\n\n    $collection-&gt;getSelect()-&gt;joinLeft(array('sfo'=&gt;'sales_flat_order'),'sfo.entity_id=main_table.entity_id',array('sfo.customer_email','sfo.weight','sfo.discount_description','sfo.increment_id','sfo.store_id','sfo.created_at','sfo.status','sfo.base_grand_total','sfo.grand_total'));\n\n    $this-&gt;setCollection($collection);\n\n    return parent::_prepareCollection();\n}\n\nprotected function _prepareColumns()\n{\n    $this-&gt;addColumn('real_order_id', array(\n    'header'=&gt; Mage::helper('sales')-&gt;__('Order *'),\n    'width' =&gt; '80px',\n    'type' =&gt; 'text',\n    'index' =&gt; 'increment_id',\n    'filter_index' =&gt; 'sfo.increment_id',\n    ));\n\n    if (!Mage::app()-&gt;isSingleStoreMode()) {\n    $this-&gt;addColumn('store_id', array(\n    'header' =&gt; Mage::helper('sales')-&gt;__('Purchased From (Store)'),\n    'index' =&gt; 'store_id',\n    'type' =&gt; 'store',\n    'store_view'=&gt; true,\n    'display_deleted' =&gt; false,\n    'width' =&gt; '40px',\n    ));\n    }\n            $this-&gt;addColumn('customer_email', array(\n    'header' =&gt; Mage::helper('sales')-&gt;__('Customer Email'),\n    'index' =&gt; 'customer_email',\n    'type' =&gt; 'text',\n    'filter_index' =&gt; 'sfo.customer_email',\n    'width' =&gt; '50px',\n    ));\n\n    return parent::_prepareColumns();\n}\n<\/code><\/pre>\n<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e78c97c2551bd635fea66b0569e86402?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBorniet<\/p>\n<p>Check your database to see the actual name of the column you&#8217;re referring to. As Mysql says in its error: the column you&#8217;re addressing doesn&#8217;t exist.<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>The Smart Dude Help. I have been struggling with this error for a few days now and have yet to find an answer. I am trying to add a few columns to the orders grid in Magento 1.6.2 I followed the instructions from: [http:\/\/www.milessebesta.com\/web-design\/magento-customize-backend-order-grid-to-have-sku-e-mail-address-and-phone-number\/][1] Here is the error message: SQLSTATE[42S22]: Column not found: 1054 Unknown [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,1],"tags":[],"class_list":["post-3496","post","type-post","status-publish","format-standard","hentry","category-magento","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=3496"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3496\/revisions"}],"predecessor-version":[{"id":9045,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/3496\/revisions\/9045"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=3496"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=3496"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=3496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}