-2

I have a database table for Contacts structured.

ID = 1    
Full_Name = Joe Bloggs    
Primary Email = SomeEmail@Test.com    
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 = SomeEmail@Test.com    
Secondary_Email = SomeEmail@Test.com    

ID = 2    
Full_Name = Ruth Jones    
Primary_Email = TestEMail@Test.com    
Secondary_Email = TestEMail@Test.com    

Thank you in advance!

  • dupe of [How can I copy data from one column to another in the same table?](https://stackoverflow.com/questions/6308594/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. – underscore_d Jul 02 '20 at 16:17

1 Answers1

1

You can just set it:

UPDATE your_table SET Secondary_Email = Primary_Email
Azelski
  • 155
  • 1
  • 2
  • 10
  • Presumably you might want to add `where Secondary_Email is null`. It's not clear from the question though. – shawnt00 Jul 02 '20 at 17:51