title: How can I use the result of one select statement as a variable in another?
body: <p>This is what I'm trying to do</p>
  
  <pre><code>WITH 
  loc_id AS ( // take the result of the following select statement
  SELECT l.location_id
    FROM mopdb.lulocation l
    WHERE (l.location_short = 'FOO'))
  
  SELECT d.device
    FROM mopdb.ludevice d
    LEFT JOIN lulocation l ON (d.location_id = l.location_id)
    WHERE (d.location_id = loc_id) //use it here 
  </code></pre>