Querying with and and or in Ibatis

Source: Internet
Author: User
Tags cdata

When you use a conditional query in your project, and you have a sudden encounter with an OR, the situation is similar: where A<1 and (b>2 OR b<1), how to write in Ibatis. That's what I wrote:

<isnotempty prepend= "and" property= "a" >

<! [cdata[

A < 1

]]>

</isNotEmpty>

<isnotempty prepend= "and (" property= "B" >

<! [cdata[

B > 2

]]>

</isNotEmpty>

<isnotempty prepend= "OR" property= "B" >

<! [cdata[

b < 1)

]]>

</isNotEmpty>

Suppose that a B in the example above corresponds to the attribute in Parameterclass is a B. How to write this or condition thought for a while, because the subconscious thought that the prepend attribute can only be and and OR, but actually the prepend attribute can be any value, it simply represents the string that is placed before the SQL statement when the condition is satisfied, whatever it is, Of course you have to make sure that the last piece of SQL is grammatically correct.

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.