Alternative notation for an empty SQL query condition O ( ̄▽ ̄) d

Source: Internet
Author: User

Simple description: Today look at the boss to submit the code, found an interesting thing, a SQL judge condition is empty, eldest brother's writing, let me before the light. Directly on the code

Code:

<select id= "Getxxxs" resultmap= "Xxxresultmap" parametertype= "String" >
Select <include refid= "Field"/>from
<include refid= "TableName" ></include>
where r.xxx_level = ' 0 '
<if test= "_parameter! = null and _parameter! =" ">
and r.xxx_id! = #{_parameter} //highlights are right here. conditional judgment is not used in empty statements again! Non-op means r.xxx_id = null or = ' '
</if>
</select>

Summary: In fact, this is not what to say, the key is a bit clever ah, record!!!

Alternative notation for an empty SQL query condition O ( ̄▽ ̄) d

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.