MyBatis如何实现一段数据库执行语句有set和select在一起的

MyBatis如何实现一段数据库执行语句有set和select在一起的

我真的不太会写,麻烦帮忙写下

set @num1 = 0,@num2 = 0,@num3 = 0,@num4 = 0;
      select     t1.license_number,t1.begin_time,t2.entry_time
    FROM
    (SELECT (@num1 := @num1 + 1) AS number,bulldozer_info.* FROM bulldozer_info WHERE license_number = "京OFV501FV606" ORDER BY BEGIN_time ) t1
    LEFT JOIN
    (SELECT (@num2 := @num2 + 1) AS number,refuse_treatment_plant.* FROM refuse_treatment_plant where license_number = "京OFV501FV606" ORDER BY entry_time ) t2
    on t1.license_number = t2.license_number  and t1.number = t2.number
    UNION
    select     t1.license_number,t1.begin_time,t2.entry_time
    FROM
    (SELECT (@num3 := @num3 + 1) AS number,bulldozer_info.* FROM bulldozer_info WHERE license_number = "京OFV501FV606" ORDER BY BEGIN_time ) t1
    RIGHT  JOIN
    (SELECT (@num4 := @num4 + 1) AS number,refuse_treatment_plant.* FROM refuse_treatment_plant where license_number = "京OFV501FV606" ORDER BY entry_time ) t2
    on t1.license_number = t2.license_number  and t1.number = t2.number
阅读 1.4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题