2021年3月17日星期三

Can I use single parameter in better-sqlite.get() or better-sqlite.all() multiple times in the same statement

I'm using better-sqlite in node to access an sqlite3 database.

Is there a way to pass a single parameter to all() or get() and use it multiple times in the statement. At the moment I'm doing this:

const statement = `SELECT * FROM table WHERE          column_1 = ?      OR          column_2 = ?      OR          column_3 = ?  `;    const param = 'something';  const results = db.prepare(statement).all(      param,      param,      param  );  

But I would like to do something like this:

const statement = `SELECT * FROM table WHERE          column_1 = ?1      OR          column_2 = ?1      OR          column_3 = ?1  `;    const param = 'something';  const results = db.prepare(statement).all(      param  );  
https://stackoverflow.com/questions/66684169/can-i-use-single-parameter-in-better-sqlite-get-or-better-sqlite-all-multipl March 18, 2021 at 11:04AM

没有评论:

发表评论