# Copying specific data in a db into the same db while changing a value

**URL:** <https://forum.inductiveautomation.com/t/copying-specific-data-in-a-db-into-the-same-db-while-changing-a-value/57583>\
**Category:** Ignition\
**Created:** [March 24, 2022, 1:21pm UTC](https://forum.inductiveautomation.com/t/copying-specific-data-in-a-db-into-the-same-db-while-changing-a-value/57583 "2022-03-24T13:21:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![christopher.raphael](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christopher.raphael](https://forum.inductiveautomation.com/u/christopher.raphael)\
**Post date:** [March 24, 2022, 1:21pm UTC](https://forum.inductiveautomation.com/t/copying-specific-data-in-a-db-into-the-same-db-while-changing-a-value/57583/1 "2022-03-24T13:21:28Z")

</div>

I have created a JSU\_PY project that is working well but I was asked to provide a button to copy the values in the DB with specific identifiers in a column and copy them with a different identifier into the same DB. Basically two fixtures on a cell have the same JSU setups and instead of inputting everything twice they want to just duplicate with a different fixture ID. Not sure how to do this nor have I ever had to. It is many rows of info.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [March 24, 2022, 1:38pm UTC](https://forum.inductiveautomation.com/t/copying-specific-data-in-a-db-into-the-same-db-while-changing-a-value/57583/2 "2022-03-24T13:38:18Z")

</div>

You would use an `INSERT...SELECT` statement. Something like this:

```auto
sql = """INSERT INTO someTable (my_id, a, b, c, d)
SELECT ? As new_id, a, b, c, d
FROM someTable
WHERE my_id=?"""

system.db.runPrepUpdate(sql, [to_id, from_id])

```

---

<div class="post-metadata">

**Author:** ![christopher.raphael](https://avatars.discourse-cdn.com/v4/letter/c/65b543/32.png) [@christopher.raphael](https://forum.inductiveautomation.com/u/christopher.raphael)\
**Post date:** [March 24, 2022, 2:36pm UTC](https://forum.inductiveautomation.com/t/copying-specific-data-in-a-db-into-the-same-db-while-changing-a-value/57583/3 "2022-03-24T14:36:09Z")

</div>

That took care of it, like I doubted you!
