Ibatis uses several XML statements for in queries

Source: Internet
Author: User

1. input parameters are Arrays

<select id="Test"  resultClass="dto">             select *             from UserInfo             where userId in                 <iterate open="(" close=")" conjunction="," >                     #[]#                 </iterate>         </select> 
Use
 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>


2. The above array can also be used as an array in the object, which is slightly different in writing.

<select id="Test"  resultClass="dto">             select *             from UserInfo             where userId in                 <iterate open="(" close=")" conjunction="," property="ArrValue" >                      #ArrValue[]#                 </iterate>         </select> 



3. Input data after in using string, but remember to use $ instead ##

<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_tmfrom eauser u,TB_USER_INFO ui         WHERE u.ACCOUNT = ui.ACCOUNT        <dynamic> <isNotEmpty prepend="AND" property="userids">                 ui.id in ($userids$)            </isNotEmpty></dynamic></select>



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.