得过且过 发表于 2018-10-20 14:43:12

怎么编写mybatis.xml文件,实现sql增删改查

  
  
  
  
  
  uid, supplier_id, license, driver_id, organization_id, car_model, car_type, frame_no, engine_no, car_price,
  oil_card, first_regist_date, insurance_date, insurance_amount, check_date, remark, create_user, create_time, update_time, update_user,carowner,
  device_no, attr1, attr2, attr3, attr4, attr5, delete_flag
  
  
  
  
  
  
  and (license like CONCAT('%',#{keyword},'%')
  OR car_model like CONCAT('%',#{keyword},'%')
  OR carowner like CONCAT('%',#{keyword},'%')
  OR frame_no like CONCAT('%',#{keyword},'%')
  OR engine_no like CONCAT('%',#{keyword},'%')
  OR oil_card like CONCAT('%',#{keyword},'%')
  OR device_no like CONCAT('%',#{keyword},'%')
  )
  
  
  and license like CONCAT('%',#{license},'%')
  
  
  and organization_id = #{organizationId}
  
  
  and car_model like CONCAT('%',#{carModel},'%')
  
  
  and carowner like CONCAT('%',#{carowner},'%')
  
  
  and car_type = #{carType}
  
  
  and frame_no like CONCAT('%',#{frameNo},'%')
  
  
  and engine_no like CONCAT('%',#{engineNo},'%')
  
  
  and car_price = #{carPrice}
  
  
  and oil_card like CONCAT('%',#{oilCard},'%')
  
  
  and first_regist_date = #{firstRegistDate}
  
  
  and insurance_date = #{insuranceDate}
  
  
  and insurance_amount = #{insuranceAmount}
  
  
  and check_date = #{checkDate}
  
  
  and remark = #{remark}
  
  
  and create_user = #{createUser}
  
  
  and update_time = #{updateTime}
  
  
  and update_user = #{updateUser}
  
  
  and device_no like CONCAT('%',#{deviceNo},'%')
  
  
  and attr1 = #{attr1}
  
  
  and attr2 = #{attr2}
  
  
  and attr3 = #{attr3}
  
  
  and attr4 = #{attr4}
  
  
  and attr5 = #{attr5}
  
  
  =#{beginTime}]]>
  
  
  
  
  
  and delete_flag = #{deleteFlag}
  
  
  and uid in(select a.carinfo_id from tb_car_info_driver a where a.delete_flag='0' and a.driver_user=#{driverUsers})
  
  
  
  
  
  
  insert into tb_car_info(
  uid, supplier_id, license, driver_id, organization_id, car_model, car_type, frame_no, engine_no, car_price,oil_card, first_regist_date,
  insurance_date, insurance_amount, check_date, remark, create_user, create_time,update_time, update_user,carowner,device_no,attr1,attr2,attr3,attr4,attr5,delete_flag
  ) values (
  #{uid}, #{supplierId}, #{license}, #{driverId}, #{organizationId}, #{carModel}, #{carType}, #{frameNo}, #{engineNo}, #{carPrice},#{oilCard}, #{firstRegistDate},
  #{insuranceDate}, #{insuranceAmount}, #{checkDate}, #{remark}, #{createUser}, #{createTime}, #{updateTime}, #{updateUser},#{carowner},#{deviceNo},#{attr1},#{attr2},
  #{attr3},#{attr4},#{attr5},#{deleteFlag}
  )
  
  
  
  insert into tb_car_info_driver (carinfo_id, driver_user, delete_flag) values
  
  (#{uid}, #{item}, #{deleteFlag})
  
  
  
  
  delete from tb_car_info where uid = #{uid}
  
  
  
  delete from tb_car_info_driver where delete_flag = '0' and carinfo_id = #{uid}
  
  
  
  delete from tb_car_info where uid in
  
  #{item}
  
  
  
  
  update tb_car_info
  
  
  license = #{license},
  
  
  driver_id = #{driverId},
  
  
  organization_id =#{organizationId},
  
  
  car_model = #{carModel},
  
  
  car_type = #{carType},
  
  
  frame_no = #{frameNo},
  
  
  engine_no = #{engineNo},
  
  
  car_price = #{carPrice},
  
  
  oil_card = #{oilCard},
  
  
  first_regist_date = #{firstRegistDate},
  
  
  insurance_date = #{insuranceDate},
  
  
  insurance_amount = #{insuranceAmount},
  
  
  check_date = #{checkDate},
  
  
  remark = #{remark},
  
  
  create_user = #{createUser},
  
  
  update_time = #{updateTime},
  
  
  update_user = #{updateUser},
  
  
  carowner = #{carowner},
  
  
  device_no = #{deviceNo},
  
  
  delete_flag = #{deleteFlag}
  
  
  attr1 = #{attr1},
  
  
  attr2 = #{attr2},
  
  
  attr3 = #{attr3},
  
  
  attr4 = #{attr4},
  
  
  attr5 = #{attr5}
  
  
  where uid = #{uid}
  
  
  
  update tb_car_info_driver set delete_flag = '1' where delete_flag = '0' and carinfo_id = #{uid}
  
  
  
  select
  
  from tb_car_info
  where uid=#{uid}
  
  
  
  select driver_user from tb_car_info_driver where delete_flag='0' and carinfo_id=#{uid}
  
  
  
  select
  ,
  (SELECTCASE WHEN TIMESTAMPDIFF(MINUTE,create_time,NOW())>5 THEN 3 ELSE STATUS END FROM tb_gps_record WHERE device_no=ci.device_no ORDER BY create_time DESC LIMIT 1) AS STATUS
  from tb_car_info ci
  
  
  order by ${orderByClause}
  
  
  limit #{offset} , #{pageSize}
  
  
  
  SELECT
  FROM tb_car_info b WHERE
  b.uid NOT IN(
  SELECT a.`carinfo_id` FROM tb_car_info_driver a where a.delete_flag='0')
  
  
  
  select count(*) from tb_car_info
  
  
  
  案例:mybatis.xml中sql编写规范

页: [1]
查看完整版本: 怎么编写mybatis.xml文件,实现sql增删改查