Home > Database > Mysql Tutorial > ibatis使用in查询的几种XML写法

ibatis使用in查询的几种XML写法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:57:59
Original
1341 people have browsed it

1.传入参数是数组 select id=Test resultClass=dto select * from UserInfo where userId in iterate open=( close=) conjunction=, #[]# /iterate /select 使用 string[] arrays = new string[] { 1, 2, 3 }; Reader.QueryForList?(Ibatisnet.dao.span styl

1.传入参数是数组

 

使用
 string[] arrays = new string[] { "1", "2", "3" }; 
 Reader.QueryForList<?>("Ibatisnet.dao.<span style="font-family: Arial, Helvetica, sans-serif;">Test</span><span style="font-family: Arial, Helvetica, sans-serif;">", strValue ); </span>
Copy after login

2.使用上面的数组还可以使用对象中数组方式,写法有点区别

<select id="Test"  resultClass="dto"> 
            select * 
            from UserInfo 
            where userId in 
                <iterate open="(" close=")" conjunction="," property="ArrValue" > 
                     #ArrValue[]# 
                </iterate> 
        </select> 
Copy after login
3. in 后面的数据,使用string传入 ,但是记住如果是:请使用$ $,而不是# #
<select id="queryAllUserinfo" parameterClass="dto"
		resultClass="dto">
		SELECT u.USERID,ui.id,
		u.USERNAME,u.ACCOUNT,u.SEX,ui.specialty,ui.address,ui.idnumber,ui.school,ui.nation,ui.political_landscape,ui.phone,ui.email,ui.qq,ui.job_category,ui.stu_class,ui.create_tm,ui.modify_tm
		from eauser u,TB_USER_INFO ui 
        WHERE u.ACCOUNT = ui.ACCOUNT
        <dynamic>
			 <isNotEmpty prepend="AND" property="userids">
                 ui.id in ($userids$)
            </isNotEmpty>
		</dynamic>
	</select>
Copy after login
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template