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游戏类型表-->
     上述完成了用户输入一个值,可以模糊匹配查询“点卡名称”,“充值游戏”,“点卡的面值”,“游戏的类型名称”来搜索结果。
  • 相关阅读:
    【poj2761】 Feed the dogs
    【bzoj1086】 scoi2005—王室联邦
    学堂在线
    【bzoj3757】 苹果树
    【uoj58】 WC2013—糖果公园
    博弈论学习笔记
    【poj2960】 S-Nim
    【poj2234】 Matches Game
    【poj1740】 A New Stone Game
    【bzoj1853】 Scoi2010—幸运数字
  • 原文地址:https://www.cnblogs.com/zeussbook/p/8748668.html
Copyright © 2011-2022 走看看