How do I remove duplicates in an SQL query without using Distinct?

拟墨画扇 提交于 2019-12-11 05:08:13

问题


There are duplicates in the results of the query below. My question is how to get rid of subTaskName duplicates without using distinct?

SELECT  tasks.priority, (SELECT tasks.name FROM tasks WHERE tasks.taskid ='11377') AS taskName,
        tasks.name AS subTaskName,u.name,tasks.deadline,tasks.created,a.duration AS durata,tasks.parentID,tasks.userid ,tasks.finished,
        tasks.estimated,tasks.taskid,tasks.section,tasks.tags
        FROM tasks 
        INNER JOIN users u 
        ON tasks.assignerid = u.userid
        INNER JOIN activities a 
        ON tasks.parentID = a.taskid
        WHERE tasks.parentID='11377' 
        ORDER BY tasks.taskid
        DESC

Use this link to see the image


回答1:


After where clause include: GROUP BY tasks.name



来源:https://stackoverflow.com/questions/21160200/how-do-i-remove-duplicates-in-an-sql-query-without-using-distinct

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!