Chella
Chella

Reputation: 1562

Display Serial Number (rownum) along with the data in mysql by eliminating the duplicates in my table?

I have a Table which contains duplicate data in one column. I want to display unique data along with the rownum or serial number. my table has fields table1(tno,tname), in where tname has duplicate values, and I want to display the unique 'tname' data.

Upvotes: 2

Views: 1734

Answers (4)

Fabio Mazzo
Fabio Mazzo

Reputation: 349

Use UUID()

select UUID() as uniqueID FROM table1

Upvotes: 0

Saharsh Shah
Saharsh Shah

Reputation: 29051

Try this:

SET @auto:=0;
SELECT @auto:=@auto+1 rownum, tname 
FROM table1 GROUP BY tname

Upvotes: 3

Chella
Chella

Reputation: 1562

Thanks for your contributions all... I got the answer. If you get the better answer than this just share..

select @rownum:=@rownum+1 sno, a.tname FROM (SELECT DISTINCT tname from Table1) a, (SELECT @rownum:=0) r  limit 60

Upvotes: 0

Sashi Kant
Sashi Kant

Reputation: 13465

Try this :

Select tname, tno
from table1
group by tname having count(*)=1

Upvotes: 2

Related Questions