How would I copy entire rows within a table and change one value?
insert into user (
user_id,account_id,user_type_cd,name,e_mail_addr,
login_failure_cnt,admin_user,primary_user
)
select * from pnet_user where account_id='1'
But now I want to change 1 to 2 on the inserted entries. But now I want to change 1 to 3 on the inserted entries. But now I want to change 1 to .... on the inserted entries. But now I want to change 1 to 1000 on the inserted entries.
It will copy and write down 1000 times (only changing id ).
I'm not completely sure I understand what you're asking. If you want to copy the records where Account_ID = 1 into new rows and change Account_ID to 2 (or whatever number), this should work for you:
insert into 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
from pnet_user where account_id='1'
Basically, replace Account_ID with the value 2. If Account_ID is a varchar, use single quotes around it instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With