Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to eliminate duplicates from select query?

Before asking this question I searched using Google but I couldn't understand or maybe could not find a solution suitable for my situation.

So, I have one Table with 10 columns, I want to eliminate duplicates from select result. And in the result all columns should be presented which has unique userID's

+-----------------------------------+------+---------------------+------+
| name                              | yr   |   some Columns      |userID|
+-----------------------------------+------+---------------------+------+
| abc                               | 2000 |                     |   10 |
| jack                              | 2000 |                     |   11 |
| dadas                             | 2000 |                     |   12 |
| jack                              | 2004 | .............       |   11 |
| jack                              | 2000 | ...........         |   11 |
| nell                              | 2006 | .............       |   13 |
| ......                            | 2000 | .............       |   1  |
| .............                     | 2000 | .............       |   2  |
| again                             | 2000 | .............       |   3  |
| again                             | 2000 |                     |   3  |
| .......                           | 1973 | .............       |   2  |
| abc                               | 2000 |                     |   10 |
like image 410
Jama A. Avatar asked Feb 15 '11 03:02

Jama A.


1 Answers

Try this one:

SELECT * FROM TABLE_NAME GROUP BY userID
like image 186
kushalbhaktajoshi Avatar answered Oct 14 '22 05:10

kushalbhaktajoshi