oracle中的!= <> ^= is null 区别

本文介绍了Oracle数据库中不等于运算符`!=`、`<>`和`^=`的用法,虽然它们在逻辑上等价,但隐含地排除了空值。在查询时,这些运算符会过滤掉null值。文章建议在处理可能包含null值的字段时,使用`IS NULL`或`IS NOT NULL`来明确判断。同时,推荐利用内置函数NVL来处理空值问题。

oracle中的!= <> ^= is null 区别

!= 、 <>、^= 三个符号都表示“不等于”的意思,在逻辑上没有本质区别

但是要主义的是三个符号在表达“不等于”含义的同时,隐含一个“不为空 is not null”的前提,所以使用时null会被过滤掉。

姓名性别
张三
王二
李是

姓名<>‘张三’ :可以查出来王二和李是
性别<>‘男’ :仅可以查出来李是,王二的性别null被默认过滤掉了

推荐:1. Oracle判断是否为空 is null or is not null
2. 使用内置函数nvl(‘李是’,‘为空’)

<include refid="selectMdmMaterialTypeAttrVo"/> <where> <if test="number != null and number != ''"> and "NUMBER" = #{number}</if> <if test="name != null and name != ''"> and name like concat(concat('%', #{name}), '%')</if> <if test="typemgrId != null and typemgrId != ''"> and typemgr_id = #{typemgrId}</if> <if test="dataType != null and dataType != ''"> and data_type = #{dataType}</if> <if test="length != null "> and length = #{length}</if> <if test="maxVal != null "> and max_val = #{maxVal}</if> <if test="minVal != null "> and min_val = #{minVal}</if> <if test="defaultVal != null and defaultVal != ''"> and default_val = #{defaultVal}</if> <if test="enumerateId != null and enumerateId != ''"> and enumerate_id = #{enumerateId}</if> <if test="enumerateTable != null and enumerateTable != ''"> and enumerate_table = #{enumerateTable}</if> <if test="unit != null and unit != ''"> and unit = #{unit}</if> <if test="isRequired != null and isRequired != ''"> and is_required = #{isRequired}</if> <if test="popupEditId != null and popupEditId != ''"> and popup_edit_id = #{popupEditId}</if> <if test="href != null and href != ''"> and href = #{href}</if> <if test="isQuery != null and isQuery != ''"> and is_query = #{isQuery}</if> <if test="isShowForm != null and isShowForm != ''"> and is_show_form = #{isShowForm}</if> <if test="isShowList != null and isShowList != ''"> and is_show_list = #{isShowList}</if> <if test="isReadOnly != null and isReadOnly != ''"> and is_read_only = #{isReadOnly}</if> <if test="orderNum != null "> and order_num = #{orderNum}</if> <if test="sortFlag != null and sortFlag != ''"> and sort_flag = #{sortFlag}</if> <if test="tip != null and tip != ''"> and tip = #{tip}</if> <if test="regularCheck != null and regularCheck != ''"> and regular_check = #{regularCheck}</if> <if test="status != null and status != ''"> and status = #{status}</if> <if test="typemgrNum != null and typemgrNum != ''"> and typemgrNum = #{typemgrNum}</if> </where> </select> 其中typemgrId 换为in的查询条件 ,如果个数太多会报错 ,如何修改
最新发布
11-14
<update id="update" parameterType="com.foresealife.newglschannel.grp.domain.TgrpAgentBaseDomain"> UPDATE t_grp_agt_base_tmp SET <if test="grpAgtName!=null"> GRP_AGT_NAME = #{grpAgtName} , </if> <if test="grpAgtName==null"> GRP_AGT_NAME = null , </if> <if test="organId!=null"> ORGAN_ID = #{organId} , </if> <if test="organId==null"> ORGAN_ID = null , </if> <if test="birthDate!=null"> BIRTH_DATE = to_date(to_char(#{birthDate},'yyyy-MM-dd'),'yyyy-MM-dd') , </if> <if test="birthDate==null"> BIRTH_DATE = null , </if> <if test="sexCode!=null"> SEX_CODE = #{sexCode} , </if> <if test="sexCode==null"> SEX_CODE = null , </if> <if test="marriageCode!=null"> MARRIAGE_CODE = #{marriageCode} , </if> <if test="marriageCode==null"> MARRIAGE_CODE = null , </if> <if test="nationCode!=null"> NATION_CODE = #{nationCode} , </if> <if test="nationCode==null"> NATION_CODE = null , </if> <if test="partyCode!=null"> PARTY_CODE = #{partyCode} , </if> <if test="partyCode==null"> PARTY_CODE = null, </if> <if test="nativeplace!=null"> NATIVEPLACE = #{nativeplace} , </if> <if test="nativeplace==null"> NATIVEPLACE = null, </if> <if test="hukou!=null"> HUKOU = #{hukou} , </if> <if test="hukou==null"> HUKOU = null , </if> <if test="email!=null"> EMAIL = #{email} , </if> <if test="email==null"> EMAIL = null, </if> <if test="contactAddress!=null"> CONTACT_ADDRESS = #{contactAddress} , </if> <if test="contactAddress==null"> CONTACT_ADDRESS = null, </if> <if test="postcode!=null"> POSTCODE = #{postcode} , </if> <if test="postcode==null"> POSTCODE = null , </if> <if test="educationCode!=null"> EDUCATION_CODE = #{educationCode} , </if> <if test="educationCode==null"> EDUCATION_CODE =null, </if> <if test="school!=null"> SCHOOL = #{school} , </if> <if test="school==null"> SCHOOL =null , </if> <if test="specialty!=null"> SPECIALTY = #{specialty} , </if> <if test="specialty==null"> SPECIALTY = null , </if> <if test="workDate!=null"> WORK_DATE = #{workDate} , </if> <if test="workDate==null"> WORK_DATE = null , </if> <if test="startWorkDate!=null"> start_work_date = #{startWorkDate} , </if> <if test="startWorkDate==null"> start_work_date = null , </if> <if test="lastCompany!=null"> LAST_COMPANY = #{lastCompany} , </if> <if test="lastCompany==null"> LAST_COMPANY =null , </if> <if test="lastPosition!=null"> LAST_POSITION = #{lastPosition} , </if> <if test="lastPosition==null"> LAST_POSITION = null , </if> <if test="insWorkYear!=null"> INS_WORK_YEAR = #{insWorkYear} , </if> <if test="insWorkYear==null"> INS_WORK_YEAR = null, </if> <if test="grpWorkYear!=null"> GRP_WORK_YEAR = #{grpWorkYear} , </if> <if test="grpWorkYear==null"> GRP_WORK_YEAR = null , </if> <if test="isSecondEntry!=null"> IS_SECOND_ENTRY = #{isSecondEntry} , </if> <if test="isSecondEntry==null"> IS_SECOND_ENTRY = null, </if> <if test="hireDate!=null"> HIRE_DATE = #{hireDate} , </if> <if test="hireDate==null"> HIRE_DATE =null , </if> <if test="signDate!=null"> SIGN_DATE = #{signDate} , </if> <if test="signDate==null"> SIGN_DATE = null , </if> <if test="conExpire!=null"> CON_EXPIRE = #{conExpire} , </if> <if test="conExpire==null"> CON_EXPIRE = null , </if> <if test="nationalityCode!=null"> NATIONALITY_CODE = #{nationalityCode} , </if> <if test="nationalityCode==null"> NATIONALITY_CODE = null, </if> <if test="cmsBankCode!=null"> CMS_BANK_CODE = #{cmsBankCode} , </if> <if test="cmsBankCode==null"> CMS_BANK_CODE = null, </if> <if test="accountNo!=null"> ACCOUNT_NO = #{accountNo} , </if> <if test="accountNo==null"> ACCOUNT_NO = null , </if> <if test="emRelTypeCode!=null"> EM_REL_TYPE_CODE = #{emRelTypeCode} , </if> <if test="emRelTypeCode==null"> EM_REL_TYPE_CODE = null , </if> <if test="emAgtName!=null"> EM_AGT_NAME = #{emAgtName} , </if> <if test="emAgtName==null"> EM_AGT_NAME =null, </if> <if test="emTel!=null"> EM_TEL = #{emTel} , </if> <if test="emTel==null"> EM_TEL = null , </if> <if test="certNo!=null"> CERT_NO = #{certNo} , </if> <if test="certNo==null"> CERT_NO = null , </if> <if test="startDate!=null"> START_DATE = #{startDate} , </if> <if test="startDate==null"> START_DATE = null, </if> <if test="endDate!=null"> END_DATE = #{endDate}+1-1/ (24 * 3600) , </if> <if test="agentGrade!=null"> AGENT_GRADE = #{agentGrade} , </if> <if test="agentGrade==null"> AGENT_GRADE = null , </if> <if test="channelType!=null"> CHANNEL_TYPE = #{channelType} , </if> <if test="channelType==null"> CHANNEL_TYPE = null, </if> <if test="phoneNo!=null"> PHONE_NO = #{phoneNo} , </if> <if test="phoneNo==null"> PHONE_NO = null , </if> <if test="grpOrgCode!=null"> GRP_ORG_CODE = #{grpOrgCode} , </if> <if test="grpOrgCode==null"> GRP_ORG_CODE = null , </if> id_type_code=#{idTypeCode} , id_no = #{idNo} WHERE id_type_code=#{idTypeCode} and id_no = #{idNo} </update>在agent_status=‘2’时,end_time_date置为当前系统时间
08-02
<update id="update" parameterType="com.foresealife.newglschannel.grp.domain.TgrpAgentBaseDomain"> UPDATE t_grp_agt_base_tmp SET <if test="grpAgtName!=null"> GRP_AGT_NAME = #{grpAgtName} , </if> <if test="grpAgtName==null"> GRP_AGT_NAME = null , </if> <if test="organId!=null"> ORGAN_ID = #{organId} , </if> <if test="organId==null"> ORGAN_ID = null , </if> <if test="birthDate!=null"> BIRTH_DATE = to_date(to_char(#{birthDate},'yyyy-MM-dd'),'yyyy-MM-dd') , </if> <if test="birthDate==null"> BIRTH_DATE = null , </if> <if test="sexCode!=null"> SEX_CODE = #{sexCode} , </if> <if test="sexCode==null"> SEX_CODE = null , </if> <if test="marriageCode!=null"> MARRIAGE_CODE = #{marriageCode} , </if> <if test="marriageCode==null"> MARRIAGE_CODE = null , </if> <if test="nationCode!=null"> NATION_CODE = #{nationCode} , </if> <if test="nationCode==null"> NATION_CODE = null , </if> <if test="partyCode!=null"> PARTY_CODE = #{partyCode} , </if> <if test="partyCode==null"> PARTY_CODE = null, </if> <if test="nativeplace!=null"> NATIVEPLACE = #{nativeplace} , </if> <if test="nativeplace==null"> NATIVEPLACE = null, </if> <if test="hukou!=null"> HUKOU = #{hukou} , </if> <if test="hukou==null"> HUKOU = null , </if> <if test="email!=null"> EMAIL = #{email} , </if> <if test="email==null"> EMAIL = null, </if> <if test="contactAddress!=null"> CONTACT_ADDRESS = #{contactAddress} , </if> <if test="contactAddress==null"> CONTACT_ADDRESS = null, </if> <if test="postcode!=null"> POSTCODE = #{postcode} , </if> <if test="postcode==null"> POSTCODE = null , </if> <if test="educationCode!=null"> EDUCATION_CODE = #{educationCode} , </if> <if test="educationCode==null"> EDUCATION_CODE =null, </if> <if test="school!=null"> SCHOOL = #{school} , </if> <if test="school==null"> SCHOOL =null , </if> <if test="specialty!=null"> SPECIALTY = #{specialty} , </if> <if test="specialty==null"> SPECIALTY = null , </if> <if test="workDate!=null"> WORK_DATE = #{workDate} , </if> <if test="workDate==null"> WORK_DATE = null , </if> <if test="startWorkDate!=null"> start_work_date = #{startWorkDate} , </if> <if test="startWorkDate==null"> start_work_date = null , </if> <if test="lastCompany!=null"> LAST_COMPANY = #{lastCompany} , </if> <if test="lastCompany==null"> LAST_COMPANY =null , </if> <if test="lastPosition!=null"> LAST_POSITION = #{lastPosition} , </if> <if test="lastPosition==null"> LAST_POSITION = null , </if> <if test="insWorkYear!=null"> INS_WORK_YEAR = #{insWorkYear} , </if> <if test="insWorkYear==null"> INS_WORK_YEAR = null, </if> <if test="grpWorkYear!=null"> GRP_WORK_YEAR = #{grpWorkYear} , </if> <if test="grpWorkYear==null"> GRP_WORK_YEAR = null , </if> <if test="isSecondEntry!=null"> IS_SECOND_ENTRY = #{isSecondEntry} , </if> <if test="isSecondEntry==null"> IS_SECOND_ENTRY = null, </if> <if test="hireDate!=null"> HIRE_DATE = #{hireDate} , </if> <if test="hireDate==null"> HIRE_DATE =null , </if> <if test="signDate!=null"> SIGN_DATE = #{signDate} , </if> <if test="signDate==null"> SIGN_DATE = null , </if> <if test="conExpire!=null"> CON_EXPIRE = #{conExpire} , </if> <if test="conExpire==null"> CON_EXPIRE = null , </if> <if test="nationalityCode!=null"> NATIONALITY_CODE = #{nationalityCode} , </if> <if test="nationalityCode==null"> NATIONALITY_CODE = null, </if> <if test="cmsBankCode!=null"> CMS_BANK_CODE = #{cmsBankCode} , </if> <if test="cmsBankCode==null"> CMS_BANK_CODE = null, </if> <if test="accountNo!=null"> ACCOUNT_NO = #{accountNo} , </if> <if test="accountNo==null"> ACCOUNT_NO = null , </if> <if test="emRelTypeCode!=null"> EM_REL_TYPE_CODE = #{emRelTypeCode} , </if> <if test="emRelTypeCode==null"> EM_REL_TYPE_CODE = null , </if> <if test="emAgtName!=null"> EM_AGT_NAME = #{emAgtName} , </if> <if test="emAgtName==null"> EM_AGT_NAME =null, </if> <if test="emTel!=null"> EM_TEL = #{emTel} , </if> <if test="emTel==null"> EM_TEL = null , </if> <if test="certNo!=null"> CERT_NO = #{certNo} , </if> <if test="certNo==null"> CERT_NO = null , </if> <if test="startDate!=null"> START_DATE = #{startDate} , </if> <if test="startDate==null"> START_DATE = null, </if> <if test="endDate!=null"> END_DATE = #{endDate}+1-1/ (24 * 3600) , </if> <if test="agentGrade!=null"> AGENT_GRADE = #{agentGrade} , </if> <if test="agentGrade==null"> AGENT_GRADE = null , </if> <if test="channelType!=null"> CHANNEL_TYPE = #{channelType} , </if> <if test="channelType==null"> CHANNEL_TYPE = null, </if> <if test="phoneNo!=null"> PHONE_NO = #{phoneNo} , </if> <if test="phoneNo==null"> PHONE_NO = null , </if> <if test="grpOrgCode!=null"> GRP_ORG_CODE = #{grpOrgCode} , </if> <if test="grpOrgCode==null"> GRP_ORG_CODE = null , </if> id_type_code=#{idTypeCode} , id_no = #{idNo} WHERE id_type_code=#{idTypeCode} and id_no = #{idNo} </update>在agent_status=‘2’时,end_time_date置为当前系统时间
08-02
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值