title: Undefined column when searching 2 columns concatenated into 1 in Postgresql
body: <h1>Problem</h1>
  
  <p>For some reason I'm getting the error:</p>
  
  <pre><code>PG::UndefinedColumn: ERROR:  column "full_name" does not exist
  </code></pre>
  
  <p>For the following query:</p>
  
  <pre><code>User.select("first_name || ' ' || last_name as full_name").where("full_name = ?", "Jon Snow")
  </code></pre>
  
  <p>Which converts into the sql query:</p>
  
  <pre><code>SELECT first_name || ' ' || last_name as full_name FROM \"users\" WHERE (full_name = 'Jon Snow')
  </code></pre>
  
  <h1>Goal</h1>
  
  <p>My intention is to be able to query by a users full name, but I don't want to split it out because this is used in a much larger query.</p>
  
  <h1>Attempts</h1>
  
  <p>I've tried a many variations of using/not using the table name (<code>users</code>) around <code>first_name</code>, <code>last_name</code>, or <code>full_name</code> and also tried adding/removing quotes/parenthesis from various locations. I've found that if I query without a <code>where</code>, and then check what <code>full_name</code> is, it actually gathers it correctly. <code>Concat</code> also seems to yield the same error.</p>
  
  <h1>Possible Solution</h1>
  
  <p>Instead of naming it, it looks like if I move the <code>concat</code> into the <code>where</code> call, it should work:</p>
  
  <pre><code>User.where("CONCAT(first_name, ' ', last_name) = ?", "Jon Snow")
  </code></pre>
  
  <p>SQL:</p>
  
  <pre><code>"SELECT \"users\".* FROM \"users\" WHERE (CONCAT(first_name, ' ', last_name) = 'Jon Snow')
  </code></pre>
  
  <p>It doesn't seem as convenient as using a named variable but maybe you just can't do that.</p>