zoukankan      html  css  js  c++  java
  • mySql一个字段的值模糊匹配多表多列的查询

    1.dao层
    /**
    * 分页查询点卡集合信息
    * @param tid 游戏类型编号
    * @param gid 游戏编号
    * @param searchInfo 包括(点卡名称,游戏名称,点卡面值,游戏类型名称)
    * @param index
    * @param pagesize
    * @return
    */
    List<Cards> searchList(@Param("tid") int tid,
    @Param("gid") int gid,
    @Param("searchInfo") String searchInfo,
    @Param("index") int index,
    @Param("pagesize") int pagesize);
    2.mybatis的xml
    <select id="searchList" resultType="Cards">
    SELECT c.*,g.`gid` AS gid,g.`gName` AS gName
    FROM `cards` AS c JOIN `gameOrCard` AS ga ON c.cid=ga.cid
    JOIN `games` AS g ON g.`gid`=ga.`gid`
    JOIN `gamestype` AS ty ON g.`tId`=ty.`tId`
    <where>
    <if test="tid>0">AND g.`tid`=#{tid}</if>
    <if test="gid>0">AND g.`gid`=#{gid}</if>
    <if test="searchInfo != null and searchInfo != ''">
    AND CONCAT_WS(
    c.`cName`,g.`gName`,c.`iniPrice`,ty.`tName`
    )LIKE CONCAT('%',#{searchInfo},'%')
    </if>
    </where>
    AND c.isShelves=0 ORDER BY g.gid
    limit #{index},#{pagesize}
    </select>
    <!--注解:cards点卡信息表;games游戏信息表;gameOrcard游戏与点卡的关系表;gamestype游戏类型表-->
     上述完成了用户输入一个值,可以模糊匹配查询“点卡名称”,“充值游戏”,“点卡的面值”,“游戏的类型名称”来搜索结果。
  • 相关阅读:
    css页面自适应 媒体查询
    微信小程序rich-text中的nodes属性
    解析base64数据流---加载pdf
    用伪元素完成箭头
    搭建vue --2.x
    搭建Vue项目 vue-cli vue1.x
    Chrome----TCP
    单进程VS多进程
    线程VS进程
    Chrome---network模块---Timing
  • 原文地址:https://www.cnblogs.com/zeussbook/p/8748668.html
Copyright © 2011-2022 走看看