Proper syntax for "WHERE column IN [ArrayOfValues]"? · Issue #82 · brianc/node-postgres (original) (raw)

@jfeldstein

I have an array of user ids, and would like to select all the users at once.

This query:

  this.db.query({
    text: "SELECT * FROM users WHERE remote_id IN <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mi>A</mi><mi>N</mi><mi>D</mi><mi>p</mi><mi>r</mi><mi>o</mi><mi>v</mi><mi>i</mi><mi>d</mi><mi>e</mi><mi>r</mi><mo>=</mo></mrow><annotation encoding="application/x-tex">1 AND provider = </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord">1</span><span class="mord mathnormal">A</span><span class="mord mathnormal" style="margin-right:0.10903em;">N</span><span class="mord mathnormal" style="margin-right:0.02778em;">D</span><span class="mord mathnormal">p</span><span class="mord mathnormal">ro</span><span class="mord mathnormal" style="margin-right:0.03588em;">v</span><span class="mord mathnormal">i</span><span class="mord mathnormal">d</span><span class="mord mathnormal" style="margin-right:0.02778em;">er</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>2",
    values: [array_of_ids, provider_string]
  }, cb);

Gives the error error: syntax error at or near "$1"

What's the correct syntax for this? Couldn't find it in the documentation or via google.

Thanks.