pg 结合mybatis查询数组id的名称

1,添加sql

    <!--  查询车辆编号  -->
    <!--suppress SqlResolve -->
    <sql id="get_car_code_car">
        select n1.code
        from base_car n1
        where n1.deleted = '0'
        and n1.id = any (tb1.car)
    </sql>

2,查询时注入

<select id = "findObsAll" resultMap="findObsAll" >
   select tb1*,
	array(<include refid="get_car_code_car"/>) carName
		  from rostering_war   tb1
		where tb1.deleted = '0'
</select>
posted @ 2023-03-29 10:32  枫·影  阅读(40)  评论(0编辑  收藏  举报