I have to add Extra field like buyer name in Admin sales order create section


In collection Add code like

        'main_table.table_field_id ='t2.field_id', array('field_name'));

New products field are coming excellently.

now we need to add one more table

field to check table_2 field_name == table_3 field_name must equal.

After adding this join query result

$collection->getSelect()->join( array(
      't2'=>'table2_to_be_joined', 't3' => 'table3_to_be_joind'),
        'main_table.table_field_id ='t2.field_id' and 't2.field_name = t3.field_name',array('field_name'));

Its showing

Unknown column 't3.field_name' in 'on clause', query

  • I have a doubt that , you have joined the table and it is updated in DB. Later you wish to add additional field in any one of the table. Then you have to write update query to join the table once again.right? – Jaisa Feb 10 '18 at 9:18
  • If it has entry already, It will show "You cannot define a correlation name more than once" issue how do u solve – Jaisa Feb 10 '18 at 9:19


    'main_table.table_field_id = t2.field_id',

    't2.field_name = t3.field_name'
  • HI R.S, Thanks for your ANS. But its shows Item (Mage_Catalog_Model_Product) with the same id "3189" already exist – GR Rajkumar Sep 28 '15 at 13:54
  • Without seeing the data set it hard to figure out why, but the error message is stating that it is returning 2 rows with the same id; so you may add a "group by" or "distinct" – Renon Stewart Sep 28 '15 at 14:00
  • Please remember to accept – Renon Stewart Sep 29 '15 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.