I want to show two table values in Admin grid using UI Component (which has no relation) so using union query it can be achieved. How to get the collection from two tables?

Table structure 1

enter image description here

Table structure 2

enter image description here

Please, someone, help me with this.

  • I wouldn't use union. you should create a table view in your database and present this data in the ui component Jan 22, 2019 at 10:37
  • I think your not able to understand my question. your talking about the single table, I want to show two table values in one custom admin grid which has no relation.
    – Amy
    Jan 22, 2019 at 10:50
  • I do understand your question. but I would create a table view. just aggregate your data in said table view. If you need to, you can use UNION in the select of the table view Jan 22, 2019 at 10:52
  • But I don't want to aggregate the data in the same table view as there are multiple tables to combine and show in admin grid as of now I am just trying with two tables.
    – Amy
    Jan 22, 2019 at 10:59
  • I have referred this link (magento.stackexchange.com/questions/149086/…) but I am not able to implement it.
    – Amy
    Jan 22, 2019 at 11:01

1 Answer 1


See the below example to join multiple tables in Magento2

  • Thanks Amit, I referred this link but for using join you must have relation.
    – Amy
    Jan 22, 2019 at 11:11
  • I can't use join query because I have a different table structures.
    – Amy
    Jan 22, 2019 at 11:12
  • Yes we need primary key and secondary(foreign) key reference for this. Jan 22, 2019 at 11:13
  • Yup, but I don't have it.
    – Amy
    Jan 22, 2019 at 11:14
  • @Amy, but you should have foreign key to join two or more tables. Jan 22, 2019 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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