Search code examples
mysqldistinct-values

Distinct value is not coming in query


I have this query

select distinct Name,ID from tbl_abc where Name like '%william jam%'

My expected result is

Anderson William James   1
William James            2

and the result coming is

Anderson William James   1
William James            2
William James            3

The data present inside table is

Anderson William James   1
William James            2
William James            3

how can i achieve this. I am trying this from last 2 hours but not getting distinct name.


Solution

  • select Name,ID
     from tbl_abc where Name like '%william jam%'
    group by Name