日期:2014-05-16  浏览次数:20669 次

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'