-2

I have a table in MySQL with two columns.

Name  Surname
Mark  A
Mark  B
Mark  C
Jonh  A
John  B
Mark  D
Dean  A

If I will make SELECT FROM query and ask only for names column i will have an array looking like this:

Mark,Mark,Mark,Jonh,Jonh,Mark,Dean

And I want an array looking like this

Mark,John,Dean

How can I do it with PHP or MySQL?

MateuszC
  • 481
  • 2
  • 5
  • 14

1 Answers1

3

Use DISTINCT:

DISTINCT specifies removal of duplicate rows from the result set.

SELECT DISTINCT `Name` FROM tablename
John Conde
  • 217,595
  • 99
  • 455
  • 496