9951 explained code solutions for 126 technologies


mysqlSelect first record from group


SELECT id, name FROM table WHERE id IN ( SELECT min(id) FROM table GROUP BY name )ctrl + c
SELECT id, name

columns to select

table

table name to select from (definition)

WHERE id IN

select only certain ids, defined by subquery

SELECT min(id) FROM table GROUP BY name

subqyery will return first (minimum) ids for each unique name value