-2

I have a problem that I can't solve with better-sqlite3 on node.js I have a table looking somewhat like this:

image of table

How can I change each rows xp, that has a level of 3 to 100? So in this example it should change id's 1 and 4 xp value to 100.

Any help is appreciated!

  • How is this problem related to your DB choice? Please provide the code you've got and explain what you've tried so far to fix the issue. – lucasreta Feb 14 '21 at 01:29

1 Answers1

0

This is a pretty basic SQL Query, you're just needing to do a WHERE on all levels that equal 3.

UPDATE tableName
SET level = 100
WHERE level = 3

Looking at the better-sqlite3 documentation, to do an UPDATE you simply need to call the function using run()

const stmt = db.prepare('UPDATE tableName SET level = ? WHERE level = ?');
const info = stmt.run(3, 100);
Cory Fail
  • 1,070
  • 8
  • 26