zoukankan      html  css  js  c++  java
  • IBatisNet 模糊查询

    最近有个项目要用IBatisNet 模糊查询 ,网上找了很久终于找到答案了``现在我把转发出来,方便像我这样的菜鸟学习

    <select id="Client_Search" resultMap="Client_AllColumns_search"  parameterClass="Client">
       SELECT
       Client.*,
       <!--要查询的字段,如果一级行业为空则不查询-->
         <isNotNull prepend="" property="FirstIndustry">
        Industry.[Industry_Name],
        Industry.[Industry_Id],
       </isNotNull>
     
       Users.[UserName],
       Users.[UserRealName],
       Users.[UserId]

       FROM Client,Users
      <!--判断是否要连接表-->
      <isNotNull prepend="," property="FirstIndustry">Industry</isNotNull>
       
       
       <isEmpty prepend="" property="BethroughItemArray" >
       <isNotEmpty prepend="," property="ItemArray">BusinessModel,Business_Note,Project</isNotEmpty>
       </isEmpty>

       <isEmpty prepend="" property="ItemArray" >
        <isNotEmpty prepend="," property="BethroughItemArray">BusinessModel,Business_Note,Project</isNotEmpty>
       </isEmpty>

       <isNotEmpty prepend="," property="BethroughItemArray" >
        <isNotEmpty prepend="" property="ItemArray">BusinessModel,Business_Note,Project</isNotEmpty>
       </isNotEmpty>
       where  Users.[UserId]=Client.[Import_User_Id] and Client.[Client_Sign]=0


       <!--一级行业-->
       <isNotNull prepend="AND" property="FirstIndustry">
        Client.First_Industry=#FirstIndustry#
        and Client.First_Industry=Industry.Industry_Id
       </isNotNull>
       <!--二级行业-->
       <isNotNull prepend="AND" property="SecondIndustry">
        Client.Second_Industry=#SecondIndustry# 
       </isNotNull>
         <!--客户名称 模糊查询-->
       <isNotEmpty prepend="AND" property="ClientName">Client.Client_Name like '%$ClientName$%'</isNotEmpty>
       <!--查询代码-->
       <isNotEmpty prepend="AND" property="ClientCode">Client.Client_Code like '%$ClientCode$%'</isNotEmpty>
         <!--其他录入人-->
       <isNotEmpty prepend="AND" property="IsUser">Client.Import_User_Id!=#ImportUserId#</isNotEmpty>
       <!--所在省-->
       <isNotNull prepend="AND" property="ProvinceID">Client.provinceID=#ProvinceID#</isNotNull>
       <!--客户编号-->
       <isNotEmpty prepend="AND" property="ClientId">Client.Client_Id  like '%$ClientId$%'</isNotEmpty>
       <!--做过的项目 在类里传一个ArrayList-->   

    <isNotEmpty prepend="AND" property="BethroughItemArray">
      
        <iterate  prepend="" property="BethroughItemArray" open="("  close=")"  conjunction="and" >
         Client.Id in (select BusinessModel.Client_Auto_Id from BusinessModel,Business_Note where Business_Note.Business_Id=BusinessModel.Business_Id
         and Business_Note.Project_Id=#BethroughItemArray[].Value#)
        </iterate>    
       </isNotEmpty>
        </select>

  • 相关阅读:
    php 类文件加载 Autoloader
    windows下配置nginx+php
    crontab 定时调度
    PHP 常见语法 集合
    php socket
    tengine + mysql + nginx + php
    yii2 [行为] behaviors 拦截器
    .htaccess 语法以及应用
    nginx 安装
    Nginx HTTP负载均衡和反向代理配置
  • 原文地址:https://www.cnblogs.com/paulxie/p/1376753.html
Copyright © 2011-2022 走看看