XpertWorlock Posted November 25, 2008 Share Posted November 25, 2008 What I want to do is go through a list of names (in one table column) and when it hits the same name twice it saves it as "x2" or something and at the end it would output Jeff x 2. So if you had 4 records (Amy, Jeff, Jeff, Stan) at the end it would output Amy Jeff x 2 Stan Can't think of a proper (non messy) way of doing this. Link to comment https://forums.phpfreaks.com/topic/134147-solved-duplicate-record-x-2/ Share on other sites More sharing options...
xtopolis Posted November 25, 2008 Share Posted November 25, 2008 This is an expensive query (I think), but it will show you the counts: SELECT DISTINCT(name), COUNT(name) as 'Amt' FROM `test` GROUP BY name and if you want to filter it to show only ones with dupes add: HAVING Amt > 2 Not sure if it is case sensitive or not. Link to comment https://forums.phpfreaks.com/topic/134147-solved-duplicate-record-x-2/#findComment-698338 Share on other sites More sharing options...
XpertWorlock Posted November 25, 2008 Author Share Posted November 25, 2008 thanks, yeah count function in mysql works great! Link to comment https://forums.phpfreaks.com/topic/134147-solved-duplicate-record-x-2/#findComment-698342 Share on other sites More sharing options...
fenway Posted November 26, 2008 Share Posted November 26, 2008 Not expensive with a proper index... you don't need distinct, group by will take care of that. And note that not using '*' in the count() treats NULLs different. Link to comment https://forums.phpfreaks.com/topic/134147-solved-duplicate-record-x-2/#findComment-699637 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.