title: ERROR: syntax error at or near "SELECT"
body: <p>I am really new to postgres. The question looks very simple but I just cant see where I got wrong. </p>
  
  <p>I a table created as follows: </p>
  
  <pre><code>  CREATE TABLE IF NOT EXISTS t(
          tn VARCHAR(30) NOT NULL,
          PRIMARY KEY(tn)
      );
  </code></pre>
  
  <p>I want to insert an instance if the instance does not exist. Here is my code: </p>
  
  <pre><code>INSERT INTO t (tn) 
  VALUES 
  (SELECT 'q' WHERE NOT EXISTS (SELECT * FROM t WHERE tn = 'q')) ;
  </code></pre>
  
  <p>And the psql console keeps giving me the error </p>
  
  <pre><code>ERROR:  syntax error at or near "SELECT"
  </code></pre>
  
  <p>I have checked every piece of code individually, for instance both </p>
  
  <pre><code>SELECT 'q' WHERE NOT EXISTS (SELECT * FROM t WHERE tn = 'q');
  </code></pre>
  
  <p>and </p>
  
  <pre><code>INSERT INTO t (tn) VALUES ('p');
  </code></pre>
  
  <p>run without error. But error occurs when I put them together. </p>
  
  <p>Does anyone know where I got wrong..?</p>