SELECT NOT IN syntax error?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
29 views
Use pg-promise for nodejs .
You need to make a selection in NOT IN condition. In the example, the option which comes array.
https://github.com/vitaly-t/pg-promise/wiki/Learn-...
I have a view object
let obj = { limit: limit list: list // array here };

The query itself:
return db.query(` SELECT * FROM table WHERE id NOT IN (${obj.list}:csv) LIMIT ${obj.limit} `);

There is a bug
{ error: syntax error (approximate position: ":")

1. What are you doing wrong?
2. How to substitute parameters in the request that all potentially dangerous characters escapees? I have correctly set up or not?
by | 29 views

1 Answer

0 like 0 dislike
What are you doing wrong?

Trying to set values by placeholder strings, instead use the formatting tools offered pg-promise (or rather - a mix of those approaches).

How to substitute parameters in the request

Yes, something like that, for example:

db.query(` SELECT * FROM table WHERE id NOT IN ($(list:csv)) LIMIT $(limit) `, obj)
by

Related questions

0 like 0 dislike
1 answer
asked Apr 23, 2019 by Link-Line
0 like 0 dislike
2 answers
0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
110,608 questions
257,187 answers
0 comments
40,796 users