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