0

How can one modify the FROM in select query without losing the left joins innerJoin etc... ? as I have tried:

$collection->getSelect()->reset(\Zend_Db_Select::FROM)->from('table_2') but then I've lost all the leftjoin concat etc...

Thanks

  • As you using reset on from then leftjoin will be lost. You have to add all of them again – Amit Bera Sep 3 at 12:01
  • @AmitBera crap that's not quite what I expected it would do but it is what it is! – Juliano Vargas Sep 3 at 13:00
  • @AmitBera I must have been doing something wrong check out my answer it works! – Juliano Vargas Sep 3 at 15:08
  • thanks.i was wrong . Thanks for correction – Amit Bera Sep 3 at 15:20
1

This works for me :

->getSelect()->reset(\Zend_Db_Select::FROM)->from(array('main_table' => 'table_2'));

I think I was doing something wrong as the above also needs the alias set and now it works!.

  • You have to add table_2 alise.greats. New thing, i learn :) – Amit Bera Sep 3 at 15:21

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.