Hi everyone,

Suppose I have a query where I want a join to be performed only if *one or more* of a set of parameters are present. Is there a way in SqlMaps to do something like this? (below is an example snippet of what I'd like to do, using some pseudocode in the first <dynamic> section):

SELECT * FROM
   table_foo f, table_bar b
<dynamic> <!-- if any of the params in the conditional are defined, add one more table to join -->
     <if>
       <or>
         <isEqual property="X.defined" compareValue="true" >
         <isEqual property="X.defined" compareValue="true"  >
       </or>
      <then>, table_baz z</then>
     </if>
  </dynamic>
  WHERE f.field = b.field
  <dynamic>
<isEqual property="X.defined" compareValue="true" prepend="AND" >z.x_field > #X.value#</isEqual> <isEqual property="Y.defined" compareValue="true" prepend="AND" >z.y_field = #Y.value#</isEqual>
 </dynamic>
Thanks,
--Vadim

Reply via email to