我想从返回的重复aspect_id(行)数量中只获得一行。
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获取不同的行?
答案 0 :(得分:1)
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;
答案 1 :(得分:1)
使用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;