我只想从返回的重复Aspect_id(rows)的数量中获得1行。

SELECT rt.taxonomy_id,rt.iteration,ra.* FROM request_taxonomy rt
inner join request_aspects ra ON ra.aspect_id = rt.request_aspects_id
                WHERE rt.requests_id = 6 and ra.section_name='Timeline';


有什么方法可以根据Aspect_id获取不同的行吗?

最佳答案

使用GROUP BY:

SELECT
    rt.taxonomy_id,rt.iteration,ra.*
FROM request_taxonomy rt
        inner join request_aspects ra ON ra.aspect_id = rt.request_aspects_id
WHERE rt.requests_id = 6 and ra.section_name='Timeline'
GROUP BY aspect_id;

关于mysql - 如何从mysql中的重复行中获取一行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33385520/

10-10 18:06