<![CDATA[select t1.* from (SELECT t1.`CUSTOMERID`, t1.`CUSTOMERNAME`, t1.`CUSTOMERTYPE` FROM (SELECT 'ACCOUNT' AS `CUSTOMERTYPE`,v1.`ACCOUNTID` AS `CUSTOMERID` ,v1.`ACCOUNTNAME` AS `CUSTOMERNAME` FROM (SELECT t1.`ACCOUNTID`, t1.`ACCOUNTNAME` FROM `ACCOUNT` t1 ) v1 UNION ALL SELECT 'CONTACT' AS `CUSTOMERTYPE`,v2.`CONTACTID` AS `CUSTOMERID` ,v2.`FULLNAME` AS `CUSTOMERNAME` FROM (SELECT t1.`CONTACTID`, t1.`FULLNAME` FROM `CONTACT` t1 ) v2 ) t1 ) t1 where customerid=#{id}]]>
<where><iftest="ew!=null and ew.sqlSegment!=null and !ew.emptyOfWhere">${ew.sqlSegment}</if></where>
<iftest="ew!=null and ew.sqlSegment!=null and ew.emptyOfWhere">${ew.sqlSegment}</if>
</select>
<!--数据查询[Account]-->
<sqlid="Account"databaseId="mysql">
<![CDATA[ select accountid as customerid, accountname as customername, 'ACCOUNT' as customertype from account
]]>
</sql>
<!--数据查询[Contact]-->
<sqlid="Contact"databaseId="mysql">
<![CDATA[ select contactid as customerid, fullname as customername, 'CONTACT' as customertype from contact
]]>
</sql>
<!--数据查询[Default]-->
<sqlid="Default"databaseId="mysql">
<![CDATA[ SELECT t1.`CUSTOMERID`, t1.`CUSTOMERNAME`, t1.`CUSTOMERTYPE` FROM (SELECT 'ACCOUNT' AS `CUSTOMERTYPE`,v1.`ACCOUNTID` AS `CUSTOMERID` ,v1.`ACCOUNTNAME` AS `CUSTOMERNAME` FROM (SELECT t1.`ACCOUNTID`, t1.`ACCOUNTNAME` FROM `ACCOUNT` t1 ) v1 UNION ALL SELECT 'CONTACT' AS `CUSTOMERTYPE`,v2.`CONTACTID` AS `CUSTOMERID` ,v2.`FULLNAME` AS `CUSTOMERNAME` FROM (SELECT t1.`CONTACTID`, t1.`FULLNAME` FROM `CONTACT` t1 ) v2 ) t1
]]>
</sql>
<!--数据查询[View]-->
<sqlid="View"databaseId="mysql">
<![CDATA[ SELECT t1.`CUSTOMERID`, t1.`CUSTOMERNAME`, t1.`CUSTOMERTYPE` FROM (SELECT 'ACCOUNT' AS `CUSTOMERTYPE`,v1.`ACCOUNTID` AS `CUSTOMERID` ,v1.`ACCOUNTNAME` AS `CUSTOMERNAME` FROM (SELECT t1.`ACCOUNTID`, t1.`ACCOUNTNAME` FROM `ACCOUNT` t1 ) v1 UNION ALL SELECT 'CONTACT' AS `CUSTOMERTYPE`,v2.`CONTACTID` AS `CUSTOMERID` ,v2.`FULLNAME` AS `CUSTOMERNAME` FROM (SELECT t1.`CONTACTID`, t1.`FULLNAME` FROM `CONTACT` t1 ) v2 ) t1