mysql多表分页查询语句_Mysql多表分页查询

多张表,字段完全相同,表名称不同,每三个月的数据插入到一张表中。当查询历史的时候,把所有表中的数据展示出来并做分页处理。

sql语句的写法:

select * from ${fristName}

where 1 = 1

and state = #{state,jdbcType = INTEGER}

and (sjrdh like concat ('%',#{number,jdbcType=VARCHAR},'%')

or hgh = #{number,jdbcType=VARCHAR})

union

select * from ${item}

where 1 = 1

and state = #{state,jdbcType = INTEGER}

and (sjrdh like concat ('%',#{number,jdbcType=VARCHAR},'%') or

hgh = #{number,jdbcType=VARCHAR})

limit

#{beginIndex,jdbcType=INTEGER},#{pageSize,jdbcType=INTEGER}


版权声明:本文为weixin_35987446原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。