Mybatis中视图的使用

视图的使用:

1.  把视图当普通的表,用select  字段  from 视图 where 的形式。如:

<select id="getListByName" parameterType="java.util.Map" resultMap="Country">

         SELECT DISTINCT countryname FROM `idc_cmdb`.view_city  
        <where>
        <if test="countryname != null">
           countryname LIKE  CONCAT('%', '${countryname}', '%')
        </if>
        </where>

    </select>


2.  like的模糊查询用CONCAT。


3.  #和$传参的区别:#是代替?,是SQL预编译;$只替换值


猜你喜欢

转载自blog.csdn.net/qq_35534449/article/details/80136155