来自 澳门威尼斯人注册网站 2019-12-04 16:28 的文章
当前位置: 澳门威尼斯人平台 > 澳门威尼斯人注册网站 > 正文

coalesce函数-返回参数中第一个非null值

Coalsece 返回第一个不是null的值

  

select top 5 [objname]

      ,[objjc]

      ,[objorder]

      ,[objid]

      ,[parentid]

      ,[grade]

      ,[type]

      ,[href]

      ,coalesce( [rel],0) rel

      FROM [Menu]



  select top 5 [objname]

      ,coalesce( [rel],'0') rel

      FROM [Menu]

     order by NEWID()



       select top 5 [objname]

      , rel

      FROM [Menu]

     order by NEWID()

 

coalesce函数-返回参数中第一个非null值

数据库中没有满足条件的id 就会报
HTTP Status 500 - Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Mapper method 'org.tsinghua.cis.dao.CisMedicineDetailsIdDao.findMedicineDetailsIdByClinicIdAndBarCode attempted to return null from a method with a primitive return type (int).

学习了:

   <select id="findMedicineDetailsIdByClinicIdAndBarCode" resultType="int">
       <![CDATA[
        SELECT
          a.`id`
        FROM
          `cis_medicine_details_id` AS  a
        INNER JOIN
          `cis_medicine_pricing` AS b
        ON
          a.id = b.medicine_details_id
        WHERE
          `medicine_bar_code` = ${medicineBarCode}
        AND
          `clinic_id` = ${clinicId}
        ]]>
    </select>

本文由澳门威尼斯人平台发布于澳门威尼斯人注册网站,转载请注明出处:coalesce函数-返回参数中第一个非null值

关键词: