0

I am trying to join two tables and trying to distinct the id of parent table.

SELECT DISTINCT ON(management_company.id) * FROM management_company INNER JOIN buildings on m_id = management_company.id ;

GetSome _
  • 59
  • 8

1 Answers1

0
knex('management_company')
  .distinctOn('management_company.id')
  .join('buildings', 'm_id', 'management_company.id')

https://runkit.com/embed/komcgnpi80d9

Mikael Lepistö
  • 18,909
  • 3
  • 68
  • 70