2

I have 2 two tables:

organisations (id, name) organisationsmeta (id, orgId, metaKey, metaValue)

Each organisation can have multiple associated meta rows. I'm using a Left Join right now since there can be organisations without any meta data.

How do I construct the query to fetch 10 organisations (with all associated meta data), regardless of how much metadata each organisation have?

1 Answers1

4
SELECT  o.*, m.*
FROM    (
        SELECT  *
        FROM    organizations
        ORDER BY
                id
        LIMIT 10
        ) o
LEFT JOIN
        organizationmeta m
ON      m.orgid = o.id
Quassnoi
  • 413,100
  • 91
  • 616
  • 614