现在有两个(或多个)表,两个(或多个)表结构一模一样问题一:查询语句返回两个(或多个)表的所有记录, 问题二:这些表中都有一个名为name的字段,我想在这些表中找出name=1的记录
各位仁兄请帮忙,!!

解决方案 »

  1.   

    问题一:
    SELECT *
    FROM Table1
    UNION
    SELECT *
    FROM Table2问题二:
    SELECT *
    FROM Table1
    WHERE name=1
    UNION
    SELECT *
    FROM Table2
    WHERE name=1
      

  2.   

    1.
    select * from ( select * from table1
    union all
    select * from table2
    union all
    select * from table3
    )a
    2.
    select * from ( select * from table1
    union all
    select * from table2
    union all
    select * from table3
    )a where name=1
      

  3.   

    在问一下各位,VB中rs.open ""中能用union,join等关键字码??谢谢
      

  4.   

    select * from 表名1 where 条件1 union select * from 表名2 where 条件2  ...前提,两个表结构必须完全一样,而且不能加order by
    使用union关键字就和以前的查询语句一样如果是动态的话,可以把语句构造字符串