mybatis中合并俩个字段使用concat函数优美解决

		  select
          tuspa.LIST_ID listId,
          tuss.SUP_NAME supName,
          #这块使用了concat函数 一般是需要拼接几个 就在中间写几个
          concat(tup.PRODUCT_CODE,'-',tup.PRODUCT_NAME) productName,
          tuspa.SUP_PRODUCT_CODE supProductCode,
          tuspa.STATE state,
          tuspa.REMARKS remarks,
          tuss.SUP_TYPE supType
          from t_uw_supplice_product_auth as tuspa
          left join t_uw_service_supplier as tuss on tuspa.SUP_ID=tuss.SUP_ID
          left join t_uw_product as tup on tuspa.PRODUCT_ID=tup.PRODUCT_ID
        <where>
            <if test="req.supId != null">
                and tuspa.SUP_ID =#{req.supId}
            </if>
            <if test="req.productId != null">
                and tuspa.PRODUCT_ID =#{req.productId}
            </if>
            <if test="req.state != null and req.state !=''">
                and tuspa.STATE =#{req.state}
            </if>
        </where>

版权声明:本文为weixin_44503925原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。