title: Can I run a MySQL query in a MySQL database field expression?
body: <p>I'm wondering how to use expressions in a MySQL database (running <code>MySQL 5.0.88</code>). I recall from my dark MSAccess ages, that expressions where quite handy, but I never tried using a query in an expression. So:</p>
  
  <p>Say I have a table with fields:</p>
  
  <pre><code> dyn_usage  (True/False)
   actual_useage
  </code></pre>
  
  <p>First field indicates whether an item is billed on actual usage (or flat fee).</p>
  
  <p>Could I then add an expression to the <code>actual_usage</code> field which contains a MySQL query (querying for the usage of the current_user like so:</p>
  
  <pre><code> &lt;!--- if dyn_usage = 1 ---&gt;
   SELECT COUNT( a.id ) AS no_of_instances
      FROM agents AS a
      WHERE a.verkaeufer = &lt;cfqueryparam value = "#Session.loginId#" cfsqltype="cf_sql_varchar" maxlength="13"&gt;
      AND a.status = "active"
  </code></pre>
  
  <p>If I can store SQL expressions, does this include parameters (I'm running Coldfusion, hence the cfqueryparam). </p>