title: Using a parameter from another query in a like clause
body: <p>I am trying to do a join and where column using an inner query. the actual query is a bit more complicated that the below but I have simplified it for this questiion. Consider I have a peopel table. I have in it two likes. The first name is George in both rows but the last_name is Lloyd and Lloyds in each row. I want to be able to return both rows. I am looking for Lloyd - returning that in the inner join and then trying to do a like int he outside query. This only returns the first row though with Lloyd. not the one with the s.</p>
  
  <p>Is it possible to do this? If I was looking for Lloyd and hardcoding it I could do </p>
  
  <pre><code>like 'Lloyd%'
  </code></pre>
  
  <p>but in my case there are many rows Im returning so I want to do it dynamically.</p>
  
  <pre><code>select * from people p
  join
   (select p1.id, p1.first_name, p1.last_name 
    from people p1 
    where p1.first_name = 'George' and p1.last_name = 'Lloyd'     and p1.id = 17)
  un on un.id = p.id
  where p.first_name = un.first_name and p.last_name like  '%' || un.last_name || '%'
  </code></pre>
  
  <p>Thanks</p>