EasyCFM.COM ColdFusion Forums / Coding Help! / Code to copy a field content to another in table

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: Code to copy a field content to another in table

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

johnny555
11-11-2002 @ 12:32 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
New Member
Posts: 10
Joined: Oct 2002

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
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

Try this code:


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

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


Thanks,
Pablo Varando
EasyCFM.COM, LLC.


Website Designed and Developed by Pablo Varando.