Mysql
 sql >> Base de données >  >> RDS >> Mysql

comment joindre la valeur d'une autre table par la même valeur de condition

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