欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

mapping select 多条件查询 遍历查询

程序员文章站 2022-04-22 19:40:16
...
 <!-- 查询查询出来的订单列表表里边包含几个学生(学生身份证号)(家长身份)-->
 <select id="queryOrderHasStudent" parameterType="com.zichen.xhkq.pojo.Order" resultType="com.zichen.xhkq.pojo.Order">
 	SELECT DISTINCT os.`xsxm`,os.`xssfz`,os.`schoolName`,os.`ddzt` FROM(SELECT * FROM `order`  
		WHERE `jtbs`=1 
		AND `xssfz`IN 
		<foreach item="xssfz" collection="stuIdCardList" open="(" separator="," close=")">
			#{xssfz}
		</foreach>
		AND `schoolId`=#{schoolId}
		AND `ddzt`=#{ddzt}
	<if test="starttime != null and !''.equals(starttime) ">
		AND `cjsj` BETWEEN #{starttime} AND NOW()
	</if>
	)os
 </select>
 
 <!-- 查询订单(家长身份)-->
 <select id="queryOrder" parameterType="com.zichen.xhkq.pojo.Order" resultType="com.zichen.xhkq.pojo.Order">
 	SELECT * FROM `order`  
		WHERE `jtbs`=1 
		AND `xssfz`IN 
		<foreach item="xssfz" collection="stuIdCardList" open="(" separator="," close=")">
			#{xssfz}
		</foreach>
		AND `schoolId`=#{schoolId}
		AND `ddzt`=#{ddzt}
	<if test="starttime != null and !''.equals(starttime)">
		AND `cjsj` BETWEEN #{starttime} AND NOW()
	</if>
 </select>
 
 <!-- 根据订单号查询对应几个学生-->
 <select id="findWhichStudent" parameterType="java.util.List" resultType="com.zichen.xhkq.pojo.Order">
 	SELECT DISTINCT `xssfz` FROM `order` WHERE 1=1
	 	<if test="ddbhmxlist.size != 0">
	 		AND `ddbhmx` in
		 	<foreach item="ddbhmx" collection="ddbhmxlist" open="(" separator="," close=")">  
		        #{ddbhmx}
		 	</foreach> 
	 	</if>
 </select>
 
 <!-- 根据订单号查询支付订单号是否在订单明细表中存在-->
 <select id="findOrder" parameterType="java.util.List" resultType="com.zichen.xhkq.pojo.Order">
 	SELECT * FROM `order` WHERE 1=1
	 	<if test="ddbhmxlist.size != 0">
	 		AND `ddbhmx` in
		 	<foreach item="ddbhmx" collection="ddbhmxlist" open="(" separator="," close=")">  
		        #{ddbhmx}
		 	</foreach> 
	 	</if>
 </select> 
 <!-- 根据订单号查询订单状态是否为未缴-->
  <select id="findIsPay" parameterType="java.util.List" resultType="com.zichen.xhkq.pojo.Order">
 	SELECT DISTINCT `ddzt` FROM `order` WHERE 1=1
	 	<if test="ddbhmxlist.size != 0">
	 		AND `ddbhmx` in
		 	<foreach item="ddbhmx" collection="ddbhmxlist" open="(" separator="," close=")">  
		        #{ddbhmx}
		 	</foreach> 
	 	</if>
 </select> 
 <!-- 根据订单号查询支付订单号在订单明细表中存在几个-->
 <select id="findOrderSize" parameterType="java.util.List" resultType="com.zichen.xhkq.pojo.Order">
 	SELECT DISTINCT `ddbh` FROM `order` WHERE `ddbh` IS NOT NULL
	 	<if test="ddbhmxlist.size != 0">
	 		AND `ddbhmx` in
		 	<foreach item="ddbhmx" collection="ddbhmxlist" open="(" separator="," close=")">  
		        #{ddbhmx}
		 	</foreach> 
	 	</if>
 </select> 

 

相关标签: select