SQL/mysql - Select distinct/UNIQUE but return all columns?

前端 未结 18 1085
忘掉有多难
忘掉有多难 2020-11-22 12:08
SELECT DISTINCT field1, field2, field3, ......   FROM table

I am trying to accomplish the following sql statement but I want it to return all colum

18条回答
  •  青春惊慌失措
    2020-11-22 12:21

    It can be done by inner query

    $query = "SELECT * 
                FROM (SELECT field
                    FROM table
                    ORDER BY id DESC) as rows               
                GROUP BY field";
    

提交回复
热议问题