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

如何在多表中查询多人的信息
有表1——表10共十个表,如果在这10个表中查询出张三,李四,王五等多人的信息,不知道这些人在表1至表10哪一个表中,求高手指教,小弟在此多谢了

------解决方案--------------------
select 1 as t ,* from 表1 where name ='张三' or name ='李四'
union all
select 2 as t ,* from 表2 where name ='张三' or name ='李四'
union all
select 3 as t ,* from 表3 where name ='张三' or name ='李四'
union all
....
select 10 as t ,* from 表10 where name ='张三' or name ='李四'