title: Node JS Postgres EXISTS and SELECT 1 Queries
body: <p>I'm trying to determine whether a user already exists in my database. I know one way to do this is by running:</p>
  <pre><code>SELECT * FROM users WHERE email = $1
  </code></pre>
  <p>and checking if the number of rows is greater than 0 or now. However, I know that a more efficient way to run this command is by using the &quot;EXISTS&quot; keyword because it doesn't need to run through all the rows in the database. However, running</p>
  <pre><code>EXISTS (SELECT 1 FROM users WHERE email = $1)
  </code></pre>
  <p>yields</p>
  <pre><code>error: syntax error at or near &quot;EXISTS&quot;
  </code></pre>
  <p>I've also tried simply running</p>
  <pre><code>SELECT 1 FROM users WHERE email = $1
  </code></pre>
  <p>as this should have the same efficiency optimizations but it doesn't output any row data.</p>
  <p>I'm using the &quot;pg&quot; driver. Any help is greatly appreciated. Thank you in advance!</p>