How can I select only the first distinct match from a field in MySQL?

后端 未结 5 1610
终归单人心
终归单人心 2021-01-14 22:49

How can I only return the first distinct match of a field in MySQL?

My Table:

name     hash
----------------
Anna     ABC
Barb     DEF
Charlie  GHI
A         


        
5条回答
  •  野的像风
    2021-01-14 23:18

    try this

    SELECT name , hash FROM my_table WHERE name LIKE '%An%'
    GROUP BY name;
    

    DEMO SQLFIDDLE HERE

提交回复
热议问题