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

StackOverflow https://stackoverflow.com/questions/13601071

  •  03-12-2021
  •  | 
  •  

Question

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.

Was it helpful?

Solution

Try this:

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

OTHER TIPS

Try this :

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

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

Use UUID()

select UUID() as uniqueID FROM table1

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top