Topic: Code to copy a field content to another in table

johnny555    -- 11-11-2002 @ 12:32 AM
  I have a table where the email column was used for login. I want to add a username column and use this column for login instead of the email column. I need to copy for each record the content of the email column to the new username column, so I will offer a first choice of username exactly to what users typed to login (email).
How do I code this?

Webmaster    -- 11-11-2002 @ 1:53 AM
  Try this code:

<!--- Get original content --->
<cfquery name="qOriginal" datasource="YourDSN">
  SELECT    *
  FROM      table
  ORDER BY  fieldID

<cfoutput query="qOriginal">
   <!--- update existing field --->
   <cfquery name="qUpdate" datasource="YourDSN">
       UPDATE        Table
       SET           UserName = '#qOriginal.Email#'
       WHERE         fieldID = #qOriginal.fieldID#
   #qOriginal.Email# (Processed)<BR>

Pablo Varando

EasyCFM.COM ColdFusion Forums :