I have a SQL query that joins two tables.

SELECT ot.name, org.name from ayakil_organization as org INNER JOIN ayakil_organization_type as ot ON org.type_id = ot.type_id ORDER BY ot.name ASC

Here ayakil_organization, ayakil_organization_type are two tables.

my resolver class is like below.

$collection = $this->_organizationFactory->create()->getCollection();
                ['ot' => 'e25_organization_type'],
                'main_table.type_id = ot.type_id',

If i use the collection query like this, i am getting an error.Can anyone help me?

  • Do you have any model files for ayakil_organization this table ? – Kishan Savaliya Nov 13 '19 at 7:01
  • yes, both tables are handles by two different modules, each tables have its own models and factory – Mujahidh Nov 13 '19 at 7:03

You can try this..

        ['ot' => 'ayakil_organization_type'],
        'main_table.type_id = ot.type_id',

This will return same query which you want.

Hope this will help you!

| improve this answer | |
  • 1
    thank you, i check and accept the answer – Mujahidh Nov 13 '19 at 7:07
  • Okay and let me know if you have any query there then :) – Kishan Savaliya Nov 13 '19 at 7:07
  • i am using factory method to get the data like this. $collection = $this->_organizationFactory->create()->getCollection(); Can i used model also with that? – Mujahidh Nov 13 '19 at 7:19
  • You can use Factory there. – Kishan Savaliya Nov 13 '19 at 7:20
  • 1
    thanks, I will check :) – Mujahidh Nov 13 '19 at 7: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.