sql
Insert data from one table to another in MySql
INSERT INTO tablename_1 (
FullName,
EmailAddress,
StatusNum
)
SELECT UserFullName,
EmailFromTable2,
'1'
FROM tablename_2
ORDER BY tablename_2_id ASC
The above code snippet can be used to insert rows from one table to another table. Here we are inserting rows into tablename_1 from tablename_2.
- UserFullName Column data from tablename_2 will be inserted into FullName column of tablename_1
- EmailFromTable2 Column data from tablename_2 will be inserted into EmailAddress column of tablename_1
- StatusNum column from tablename_1 will be assigned a value '1' in all rows.
Was this helpful?
Similar Posts