I have 2 two tables:
organisations (id, name) 开发者_JS百科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?
SELECT o.*, m.*
FROM (
SELECT *
FROM organizations
ORDER BY
id
LIMIT 10
) o
LEFT JOIN
organizationmeta m
ON m.orgid = o.id
精彩评论