Reputation: 937
I want to get only 1 row from the number of duplicate aspect_id(rows) returned.
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';
Is there any way to get the distinct rows based on aspect_id?
Upvotes: 0
Views: 29
Reputation: 2388
Use 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;
Upvotes: 1
Reputation: 448
GROUP BY
can help you
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;
Upvotes: 1