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?
SELECT o.*, m.*
FROM (
SELECT *
FROM organizations
ORDER BY
id
LIMIT 10
) o
LEFT JOIN
organizationmeta m
ON m.orgid = o.id
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.