I would like to create an internal tool that will copy the rows from a table called user_project which hosts data for users to which projects they have access too.
My goal is to copy the rows from that table and filter it by the userID to a target userID with the same access level. I would like to copy access from one user to another.
I built an input field to input the userID with the access I would like to copy and another input field to the target userID to which the access should be given.
I'm stuck in the part where I will need to copy the rows from the original user to the new user; any help will be greatly appreciated!
Basically, on the left-hand side, I input the user where I want to copy the lines from, each line representing access to a project. In contrast, on the right-hand side, I have the target userId, e.g., the user that will get the same level of access to the projects of the user from the left.
My goal is to use the button to copy the lines from the left user to the right user.
Hi @victoria I would like to update the DB so that the lines from the left table will be added to the right table (but not remove the existing lines in the right table)
Sounds good! Would something like this query work for you? It's a bulk insert query that inserts the selected rows from table1 into the underlying database populating table2. It also runs the underlying query (getProjects) on success to make sure that the data showing in table2 is updated/accurate.
Let me know if this works or if you have any questions!
QQ - in my scenario, both of the tables are the same table in the DB, user_project, and they are filtered per the user input.
How can I make sure that I'm moving the data from the left-sorted table to the right one? Maybe I think that the GUI mode is not the right approach and maybe to write it in SQL?
Oh, same table! That should also be fine to write in either the GUI mode or SQL mode as long as you modify the records to insert to match the intended IDs.
For example, I'm giving the new row a new ID so when we insert it into the same table, the info will be linked to the new ID: