How To Insert Data From A Select



TODO:

Have you ever wanted to insert data by selecting values from a table?


SOLUTION:

Consider we have a table called XMLData, and it has a column called Id, Type, RawData

 

INSERT INTO XMLData (RawType, RawData)
SELECT 'Client', RawData FROM XMLData WHERE RawType = 'Customer'

 

NOTES:

The example above will copy records flagged as RawType = 'Customer', and insert them as new records, changing the RawType to 'Client'



Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading