javascript - Knex - updating rows where value from select -
i using sqlite3 db , have these 2 tables.
list:
- id
- originid
attributes:
- id
- listid
- originlist
attributes.originlist == list.originid
i need update rows in attributes match current list.id. using knex , current raw query looks this:
update attributes set listid = (select id list originid = attributes.originlist)
i started dbs , have been trying come ways without raw, haven't been successful. there such way?
something should create raw query mentioned in op:
knex('attributes').update({ listid: knex('list').select('id').where('originid', knex.raw('??', ['attributes.originlist'])) })
Comments
Post a Comment