-2

I have a database table for Contacts structured.

ID = 1 Full_Name = Joe Bloggs Primary Email = [email protected] Secondary Email = Null 

is it possible to use an SQL query to duplicate the primary email into the secondary email for each contact like so:

ID = 1 Full_Name = Joe Bloggs Primary_Email = [email protected] Secondary_Email = [email protected] ID = 2 Full_Name = Ruth Jones Primary_Email = [email protected] Secondary_Email = [email protected] 

Thank you in advance!

1
  • dupe of How can I copy data from one column to another in the same table? and should be answered by any half-decent intro to SQL. I don't see why you would duplicate in this case, though; I'd expect Secondary_Email to be null if there was only a primary address. That said, perhaps this would be best expressed as a related table of email addresses and types/priorities/etc per person. Commented Jul 2, 2020 at 16:17

1 Answer 1

1

You can just set it:

UPDATE your_table SET Secondary_Email = Primary_Email 
Sign up to request clarification or add additional context in comments.

1 Comment

Presumably you might want to add where Secondary_Email is null. It's not clear from the question though.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.