Hi,

I have an issue that I cannot find a solution with iBatis.  Here's the scenario.

I have two tables, say "TBL1" and "TBL2".  TBL1 has two fields say "TBL1_FLD1" and TBL1_FLD2" and TBL2 has one field, say "TBL2_FLD1".

I want to create a dynamic query such that if either property for TBL1_FLD1 or TBL1_FLD2 exist then include the table TBL1 in the FROM clause.

e.g.,

SELECT TBL2.TBL2_FLD1
FROM
    TBL2
    <isNotEmpty prepend="," property="propertyForTbl1_fld1 OR propertyForTbl1_fld2">TBL1</isNotEmpty>
WHERE
    some clause


That is, I only want to include "TBL1" in the FROM clause only if either one of the property for fld1 or fld2 is not empty.  Now, I can do the following:

SELECT TBL2.TBL2_FLD1
FROM
    TBL2
    <isNotEmpty prepend="," property="propertyForTbl1_fld1">TBL1</isNotEmpty>
    <isNotEmpty prepend="," property="propertyForTbl1_fld2">TBL1</isNotEmpty>
WHERE
    some clause


But, this could put the TBL1 in the FROM clause twice.

Any help is greatly appreciated.

thanks,
sgs.

Reply via email to