sql - Copy rows and change 1 value? -


how copy entire rows within table , change 1 value?

 insert user (      user_id,account_id,user_type_cd,name,e_mail_addr,      login_failure_cnt,admin_user,primary_user  )  select * pnet_user account_id='1' 

but want change 1 2 on inserted entries. want change 1 3 on inserted entries. want change 1 .... on inserted entries. want change 1 1000 on inserted entries.

it copy , write down 1000 times (only changing id ).

i'm not sure understand you're asking. if want copy records account_id = 1 new rows , change account_id 2 (or whatever number), should work you:

insert user (user_id,account_id,user_type_cd,name,e_mail_addr,      login_failure_cnt,admin_user,primary_user) select user_id,2,user_type_cd,name,e_mail_addr,      login_failure_cnt,admin_user,primary_user  pnet_user account_id='1' 

basically, replace account_id value 2. if account_id varchar, use single quotes around instead.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -