I am using an sqlite3 DB and have these two tables.
List:
Attributes:
Attributes.OriginList == List.OriginID
I need to update rows in Attributes to match the current List.ID. I am using Knex and my current raw query looks like this:
UPDATE Attributes
SET ListID = (SELECT ID
FROM List
WHERE OriginID = Attributes.OriginList)
I just started with DBs and have been trying to come up with ways to do this without raw, but haven't been successful. Is there such a way?
Something like this should create the RAW query mentioned in OP:
knex('Attributes').update({
ListID: knex('List').select('ID').where('OriginID', knex.raw('??', ['Attributes.OriginList']))
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With