-2

I tried the below query but it not works.

Select DISTINCT firstname,lastname from users;

I need the DISTINCT records of first and last name.

This is the records:

first name | lastname | language_known
sakthi     | vel      | English
hari       | Prasath  | Chinese
Varun      | Kumar    | English

I need the above three results but need to remove the duplication of English which come two times in the result

piotrgajow
  • 2,880
  • 1
  • 22
  • 23
sakthi
  • 1
  • 3
  • What do you mean it does not work? Can you give example with data, result and your expected result? – piotrgajow Jul 01 '16 at 12:40
  • `select distinct a,b,c from ... ` means distinct for the whole lot – Drew Jul 01 '16 at 12:41
  • you can used group by clause `SELECT firstname,lastname FROM users GROUP BY firstname,lastname` – NikuNj Rathod Jul 01 '16 at 12:42
  • You need to do a group by firstname, lastname, in some subquery/derived table and pontificate how you want to deal with TieBreaks: ie, which one to choose ... because you are going to lose data with this concept but that is what you seem to want. – Drew Jul 01 '16 at 12:43
  • 1
    Possible duplicate of [MySQL SELECT DISTINCT multiple columns](http://stackoverflow.com/questions/12188027/mysql-select-distinct-multiple-columns) – Mumpo Jul 01 '16 at 12:47
  • How do you want to remove duplication of English, and still keep three results? What result do you want to get? – piotrgajow Jul 01 '16 at 13:10

1 Answers1

0
Select DISTINCT firstname,lastname from users;

called on this data you have presented will first of all select first name and last name from the table, resulting in:

firstname | lastname 
sakthi    | vel      
hari      | Prasath  
Varun     | Kumar

And then will remove the duplicate rows, however there are no duplicates in this result set, so it will be returned as is:

firstname | lastname 
sakthi    | vel      
hari      | Prasath  
Varun     | Kumar    

What result do you want to get?

piotrgajow
  • 2,880
  • 1
  • 22
  • 23