国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - Java教程 - Mybatis 條件查詢 批量增刪改查功能

Mybatis 條件查詢 批量增刪改查功能

2020-11-22 22:44番號 Java教程

這篇文章主要介紹了mybatis 腳本處理語句之條件查詢 批量增刪改查功能,需要的的朋友參考下吧

模糊查詢:

?
1
2
3
4
@Select({
    "SELECT * FROM account where account like CONCAT('%',#{query},'%') or email like CONCAT('%',#{query},'%')"
})
Account findAccountByAccountOrMail(@Param("query") String query);

批量添加:

?
1
2
3
4
5
6
7
8
9
@Insert({
    "<script>" +
        "INSERT INTO company_label(company_id,label_id) values " +
        " <foreach collection=\"item\" item=\"item\" index=\"index\" separator=\",\" > " +
        "    (#{companyId},#{item}) " +
        "  </foreach>" +
        "</script>"
})
void insertLabelForCompany(@Param("companyId") Long companyId,@Param("item") List<Long> item);

批量刪除:

?
1
2
3
4
5
6
7
8
@Delete({
    "<script>delete from company_label where company_id = #{companyId} and label_id in " +
        "<foreach collection = \"item\" item = \"item\" open=\"(\" separator=\",\" close=\")\">" +
        "#{item}" +
        "</foreach>" +
        "</script>"
})
void removeLabelForCompany(@Param("companyId") Long companyId,@Param("item") List<Long> item);

批量修改:

?
1
2
3
4
5
@Update(value = "<script>" + "update banner b set b.display = #{status} where b.id in "+
    "<foreach item = 'item' index = 'index' collection = 'ids' open = '(' separator = ',' close = ')'>#{item}</foreach>" +
    "" +
    "</script>")
int updateStatus(@Param("status") Long status, @Param("ids") Long[] ids);

批量查詢:

?
1
2
3
4
5
6
7
@Select({
    "<script>" +
        "select * from product where id in" +
        "<foreach item = 'item' index = 'index' collection = 'idList' open = '(' separator = ',' close = ')'>#{item}</foreach>" +
        "</script>"
})
List<Product> findByIdList(@Param("idList")List<Long> idList);

條件查詢,if里面不僅可以判空,還可以判斷是否滿足某個條件

?
1
2
3
4
5
6
7
8
9
@Select({
      "<script>SELECT * FROM company where 1=1 and parent_id = #{companyId} " +
          //平級
          "<if test = \"isScanSameLevelValue == 1\">and type = #{type}</if>" +
           "<if test = \"isScanSameLevelValue == 0\">and type != #{type}</if>" +
 
          "</script> "
  })
  List<Company> findCompanyConditional(@Param("isScanSameLevelValue") String isScanSameLevelValue, @Param("isScanParentLevelValue") String isScanParentLevelValue, @Param("companyId") Long companyId, @Param("type") Integer type);

條件查詢:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
*/
@Lang(XMLLanguageDriver.class)
@Select({"<script>select DISTINCT p.* FROM `us_product`.`hot_category_surgery` hcs "+
    "LEFT JOIN `us_product`.`product` p ON hcs.`product_id` =p.`id`"+
    "LEFT JOIN `us_product`.`category_surgery` cs on cs.`product_id` =p.`id`"+
    "LEFT JOIN `us_product`.`merchant_product` mp on mp.`product_id` = p.`id`"+
    "LEFT JOIN `us_product`.`org_product` op on op.`product_id` =p.`id`"+
    "where p.`type` =1 and p.`is_for_sale` =1 "+
    "        <if test=\"hId != null\"> and hcs.hot_category_id = #{hId} and p.id = hcs.product_id</if>" + //熱門類目id
    "        <if test=\"categoryId != null\"> and cs.category_id = #{categoryId} and p.id = cs.product_id</if>" + //類目id
    "        <if test=\"input != null\">    and (p.name like CONCAT('%',#{input},'%') or p.company like CONCAT('%',#{input},'%')) </if> "//用戶輸入,包括商品名和店鋪名,模糊
    "        <if test = \" location != null\"> and p.location like CONCAT('%',#{location},'%') </if> "+    //位置..
    "        <if test=\"method != null\">   and mp.filter_id = #{method} and p.id = mp.product_id</if> "//篩選條件  手術方式
    "        <if test=\"org != null\">     and op.filter_id = #{org} and p.id = op.product_id</if> "+   //篩選條件  所屬機構
    "         ORDER BY sale_volume DESC"+
    "        </script>"
})
List<Product> findProductFromLocal(@Param("hId")Long hId,@Param("categoryId")Long categoryId,@Param("input")String input,@Param("method")Long method,@Param("org")Long org,@Param("location")String location);

以上所述是小編給大家介紹的Mybatis 條件查詢 批量增刪改查功能,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對服務器之家網站的支持!

原文鏈接:http://blog.csdn.net/c568254965/article/details/73527347

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 色综合888| 蜜桃精品在线 | 亚洲日本国产 | 午夜av免费 | 久久综合九色综合欧美狠狠 | 91视频久久 | www免费在线观看 | 中文字幕久久久 | 韩日欧美| 亚洲欧洲自拍 | 久久成人人人人精品欧 | 欧美日韩在线一区 | 国产在线精品一区 | 国产精品视频久久久 | 性色av一区二区三区 | 精品无码久久久久久国产 | 黄色毛片在线 | 免费视频一区二区 | 色橹橹欧美在线观看视频高清 | 日韩欧美在线一区 | 欧美成人精品一区二区三区 | 精品国产91亚洲一区二区三区www | 欧美 亚洲 一区 | 久久久久久久97 | 国产美女精品一区二区三区 | 九九九久久国产免费 | 欧美黄色一级片免费看 | 欧美 亚洲 另类 激情 另类 | 一级黄免费看 | 日韩精品一区二区在线观看 | 亚洲成人精品av | 九九热免费精品视频 | 男女18免费网站视频 | 中文字幕视频三区 | 国产一区亚洲 | 狠狠操影院 | 搞黄免费视频 | 国产一区二区三区免费在线观看 | 久久亚洲综合 | 精品国产鲁一鲁一区二区在线观看 | 一区二区三区有限公司 |