MySQL的多表查询~解决方案

MySQL的多表查询~~

一个数据库内有多于600个表,每个表的字段都完全一样~~

每个表内大约有40W条记录,我现在要在所有表内查询所有符合 userid=’1’的记录~~有什么好办法?



狂人呀,没有做过!




用动态sql,自动拼写成一句sql,然后执行


SQL code

select * from table1 where userid='1'
union
select * from table2 where userid='1'
union
select * from table3 where userid='1'
union
...
select * from table600 where userid='1'


                        
  
  
                    
MySQL的多表查询~解决方案

相关文章:

你感兴趣的文章:

标签云: