select m.id, p.post_name, m.meta_value
from posts p
inner join post_meta m on p.id = m.post_id
inner join
(
select post_id, min(id) as minid
from post_meta
group by post_id
) m2 on m.post_id = m2.post_id and m.id = m2.minid
select m.id, p.post_name, m.meta_value
from posts p
inner join post_meta m on p.id = m.post_id
inner join
(
select post_id, min(id) as minid
from post_meta
group by post_id
) m2 on m.post_id = m2.post_id and m.id = m2.minid