MyBatis怎么实现set和SELECT同时存在的MySQL查询语句
这段查询语句怎么用MyBatis实现?
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MyBatis 本身就可以多语句
数据库可能需要开多语句,比如MySQL要给URL加 allowMultiQueries=true