Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
SQL assign infinite params

Usually we will use SQL queries like below, we will pass params with predifined number $1

queryRunner.query('SELECT * FROM sample_data WHERE code IN ($1)', ['1'])

But I want to pass multiple params without predifined $1. Any way to resolve this?

queryRunner.query('SELECT * FROM sample_data WHERE code IN ($$)', ['1','2','3'])
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

One approach dynamically builds the IN clause based on the expected number of parameters. Consider:

var params = ['1','2','3'];
var inClause = '?' + ', ?'.repeat(params.length - 1);
var sql = 'SELECT * FROM sample_data WHERE code IN (' + inClause + ')';
console.log(sql);

Once we have a statement with the right number of placeholders, we can simply bind the collection or array with no trouble.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!