我有6张表
分别是:
t1,t2,t3,t4,t5,t6
这6张表都有个相同的字段ifm
我想同时查询这6张表....把所有的表中ifm=1的信息都调取出来..
SQL语句改怎么写啊???我是这样写的...但是只要有一个表的ifm不等于1,其他所有表的信息都查不出来...
select * from t1,t2,t3,t4,t5,t6 where t1.ifm=t2.ifm=t3.ifm=t4.ifm=t5.ifm=t6.ifm=1;
应该怎么写啊?????

解决方案 »

  1.   

    如果6个表的表结构都是一样的,可以这样select * from t1 where ifm=1
    union all
    select * from t2 where ifm=1
    union all
    select * from t3 where ifm=1
    union all
    select * from t4 where ifm=1
    union all
    select * from t5 where ifm=1
    union all
    select * from t6 where ifm=1
      

  2.   

    这样貌似不行..
    6个表的结构都是不同的....只有这个ifm字段是一样的..........
      

  3.   

    select title from t1 where ifm=1
    union all
    select title  from t2 where ifm=1
    union all
    select title  from t3 where ifm=1
    union all
    select title  from t4 where ifm=1
    union all
    select title  from t5 where ifm=1
    union all
    select title  from t6 where ifm=1把* 改成title ,他们还有个共同的字段title ....
    这样可以了.......
    多谢二楼提醒....