Jump to content

[SOLVED] duplicate record X 2


XpertWorlock

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.