MySQL Forums
Forum List  »  Newbie

Re: Copy duplicate values to new column
Posted by: Peter Brawley
Date: April 28, 2017 09:39AM

> I have a database where identifier is email address.

You appear to mean a table.

> If an email address appear once or twice (not 3 times or above)

If your 'identifier' has dupes, it's not an identifier. Read about primary keys and unique keys.

> I want a value in column « A to be moved to a new column, « B »

A fundamental aim of relational database design is to minimise redundancy. Your table already has a redundancy problem--duplicate key values. Your proposed fix would increase redundancy further.

Your table needs a primary key---otherwise it's not a real table. It's not an arbitrary requirement---in order to reliably and precisely change values in a single row, you need a absolutely reliably unique identifier, and that's what a PK is.

Email address is very likely not a good PK candidate (PKs shouldn't change much if at all, IAC sometimes people or processes share email addresses).

Once you select or add a PK, you'll be able to deal with your dupe email addresses. If we're to help you with that, we'll need to know what the problem is that you're trying to solve, and what benefit you expected to derive from copying dupes to a new column.

Options: ReplyQuote


Subject
Written By
Posted
Re: Copy duplicate values to new column
April 28, 2017 09:39AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.