Home  >  Q&A  >  body text

java - 根据月份查询多个表里的内容怎么实现好?

有12个一样结构的表,分别记录十二个月份的相关信息。
用户可以选择起始月份,结束月份,查询信息。表名类似XXXX_2017_01,XXXX_2017_12这样,
我得先根据用户传入的月份拼接表名,再用UNION ALL进行查询?但是查询出来的LIST里面就不知道每条记录是属于哪个表的了。
MYBATIS应该怎么写好?

大家讲道理大家讲道理2744 days ago516

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-04-18 10:49:55

    1. If you don’t consider sql injection, you can search the difference between #{} and ${} on Baidu, then upgrade the sql statement to the business level and treat it as business processing. After splicing, use ${} to pass it into the atomic layer

    2. Checked 12 times

    reply
    0
  • Cancelreply