I have two tables users and emails:
USER
+--------+-------+--------+--------+
| id (PK)| email | email2 | email3 |
+--------+-------+--------+--------+
EMAIL
+---------+--------------+---------------+
| id (PK) | user_id (FK) | email_address |
+---------+--------------+---------------+
I need to select emails from users table and insert them into emails table as rows.
If your email table id has identity i would do it like this
INSERT INTO email (userid,email_address)
SELECT id, email FROM user
UNION SELECT id, email2 FROM user
UNION SELECT id, email3 FROM user
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments