MYSQL returning duplicate rows

后端 未结 3 923
生来不讨喜
生来不讨喜 2021-01-16 10:57

I have a Database table in MYSQL, it looks like this:

Project_ID  user_ID  name
11          1        fred
11          2        rick
11          1        fred         


        
相关标签:
3条回答
  • 2021-01-16 11:23
    $results = // query
    $results = array_unique($results);
    
    0 讨论(0)
  • 2021-01-16 11:33

    Point 1 is that should the user be assigned to the project twice?

    Point 2 - Use the DISTINCT keyword to return only unique records - http://dev.mysql.com/doc/refman/5.0/en/distinct-optimization.html

    SELECT DISTINCT user_ID
    FROM TABLE
    WHERE Project_id = 11
    

    That will return you 1 and 2 (You won't get 1 twice)

    Thanks

    0 讨论(0)
  • 2021-01-16 11:35

    Use DISTINCT

      SELECT DISTINCT user_ID
           , verschil_ma 
        FROM project_uren 
       WHERE project_ID = 11
    GROUP BY user_ID
    
    0 讨论(0)
提交回复
热议问题