<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="cn.iocoder.yudao.module.app.car.mapper.AppCarMainMapper">

    <select id="getUserCarMain" resultType="cn.iocoder.yudao.module.app.car.vo.AppCarMainResVo">

        SELECT main.*, brand.brand_name as brandName, brand.logo_img as logoImg
        from (select main.*
              from base_customer_car car
                       INNER JOIN base_car_main main on car.car_id = main.id
              where car.cus_id = (
                  select id
                  from base_customer_main
                  where user_id = #{userId}
                    and deleted = 0
              )
                and main.deleted = 0) as main
                 LEFT JOIN base_car_brand brand on main.car_brand = brand.id
    </select>
</mapper>