mysql+mybatis一个sql里执行多条语句配置

阅读更多
在数据库连接源上加入allowMultiQueries=true,如下所示:

jdbc.jdbcUrl=jdbc:mysql://127.0.0.1:3306/databaseName?useUnicode=true&characterEncoding=utf8&allowMultiQueries=true



mybatis对应的sql文件写法:

		
		DELETE FROM ad_profit_day WHERE rpt_date=#{rptDate,jdbcType=DATE} ;

		
		INSERT INTO ad_profit_day
		(
		rpt_date,profit,self_percent,reward_price,inout_profit
		)
		SELECT rpt_date,
		        COALESCE(MAX(CASE WHEN menu='A' THEN profit ELSE NULL END),0) AS profit,
		        MAX(self_percent) AS self_percent,
		        MAX(reward_price) AS reward_price, 
		        0 AS inout_profit
		 FROM base_info
		 GROUP BY rpt_date;
		 
		 //这里还可以继续添加sql语句,用分号结尾



你可能感兴趣的:(sql,mybatis)