MySQL Select rows on first occurrence of each unique value

后端 未结 5 1161
迷失自我
迷失自我 2020-12-08 04:06

Let\'s say you have the following table (the column of interest here is cid):

+-----+-------+-------+-------+---------------------+-------------         


        
5条回答
  •  星月不相逢
    2020-12-08 04:47

    I know it's an old thread, the accepted solution would only retrieve me the columns that had more than one occurrence.

    This worked for me:

    SELECT cid, pid, rid, clink, MAX(time), snippet 
    FROM mytable 
    GROUP BY cid
    

提交回复
热议问题