In postgresql I want to do something like this
update users set salary_account_id =
(insert into salary_accounts(some_field) values(1) returning salary_account_id)
I want for every record in user table to create corresponding salary_account record and then update users table with corresponding newly created salary_account_id
If I run this query I get an error 'syntax error at or near "into"'.
insertinto a function, which would do the insert and return the new ID. This can't be done as written.usersandsalary_account? I can't imagine you want to change all users to the salary_account_id you have just inserted