Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.