title: emulate function call in a stored procedure
body: <p>(The following queries are extreme simplification of the actual ones, for sake of clear code)  </p>
  
  <p>I have a stored procedure which has a query in it:  </p>
  
  <pre><code>SELECT
     f1,
     f2
  FROM
     T1
  WHERE
     T1.id IN (SELECT complex_id FROM t2 WHERE complex='condition')
  </code></pre>
  
  <p>I would like to reuse the inner query <code>(SELECT complex_id FROM t2 WHERE complex='condition')</code> in other stored procedures, but maintain it's syntax in <strong>only one place</strong>.<br>
  How would I achieve this, using DB objects (SP,Triggers etc) and <strong>no</strong> outside code (like PHP etc).</p>