I'm trying to write a query to duplicate a selected table rows data – adding it to the same table just with a new auto-incrementing ID.
It doesn't seem like the 'columns' property is available? Not sure where I'm going wrong.
INSERT INTO maintenance_requests ({{table23.selectedRow.columns}})
SELECT {{table23.selectedRow.columns}}
FROM maintenance_requests
WHERE request_id = {{table23.selectedRow.request_id}};
If possible, I'd highly recommend using the GUI mode so that you don't have to worry as much about syntax.
To insert a new row with the same data that is in your selected row, I'd use a GUI mode query like this one. I'm using lodash's _.omit to remove the id, which is the primary key for my table so that the primary key just auto increments
Hi Tess, that's exactly what I was looking for thank you.
{{_.omit(table23.selectedRow, ['request_id'])}}
When i preview my query, it removes my 'request_id' as it should, but when i actually run the query on a selected row i get this error:
invalid input syntax for type integer: "Open""
My Postgres database table i'm trying to insert the data into, has a foreign key set up for my Status, so in the table i'm trying to insert what the mapped value was on the table for that column.
Natively the status comes in as a number, but as you see I change it to read something different.
Somehow I need that column changed back to it's original (a number) before inserting data. Not sure even how to do that.