因为一段sql 要关联 a,b,c三个表,查三个表里的数据
一开始写的是
lect * from a,b,c
结果出来很元旦板报多重复数据
而三个表是用id关联的
所以改成
lect * from a where id in (lect id from a,b,c 关联条件)
然后在mybatis里在写级联查询
把b,c表里的数据以数组的形式查出来
ok了 避免了数据重复一大堆
但是人说,级联查询,缺点: 查询速度慢
如果用exists 查的比较快
加<![cdata[ ]]>即可,要么用存视图,应用在局部也可
<lect id="lectfirm" resulttype="com.esteel.web.entity.cusfirmbean" parametertype="com.esteel.web.beanvo.cusfirmbeanvo"><![cdata[lect a.*,a.customer_name as customername from tb_cus_firm a where a.market_key = #{marketkey} order by customer_key]]></lect>
<lect id="getemailcount" parametertype="map" resultmap="account1map">lect * from tb_cconcern的用法us_ur where 1=1 <if test="email!=null and email!=''"> and e烧伤疤痕mail=#{email} </if> <if test="cus_trade_kind!=null and cus_trade_kind!=''"> and cus_trade_kind =#{cus_trade_kind} </if> <if test="cus_ur_key!=null and cus_ur_key!=''"> and cus_ur_key <![cdata[<>]]> #{cus_ur_key} </if></lect>
以上为个人经验,希望能给大家一个参考,也希望大家多多支持www.887551.com。
本文发布于:2023-04-04 14:01:46,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/cc5f93862cfd9d5b7ecbbfa9bc7f7460.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:聊聊mybatis sql的括号问题.doc
本文 PDF 下载地址:聊聊mybatis sql的括号问题.pdf
留言与评论(共有 0 条评论) |