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}

             

       

你可能感兴趣的:(Mysql)