'ACCESS数据库.'有A表和B表SQL = "select * from A表 where Nu='" & form18.Text2.Text & "'"'这样只能查一个表的数据出来,如何才能也把B表的也查出来呢?

解决方案 »

  1.   

    select a.*,b.*
    from a,b
    where a.id=b.pid
    and Nu='" & form18.Text2.Text & "'"
      

  2.   

    A B表什么关系?
    例如:
    select a.*,b.* 
    from a 
    left outer join b on a.ID=b.ID
      

  3.   

    要看两个表的关系
    《数据库多表连接查询详解》http://blog.csdn.net/flyingBox/archive/2006/03/13/623189.aspx
      

  4.   

    谢谢两位..select a.*,b.* 
    from a,b 
    where a.id=b.pid 
    and Nu='" & form18.Text2.Text & "'" '如果不要A.id=B.pid 为什么提示"至少一个参数没有被指定" 点击调试就显示 rs.Open SQL, cn, 1, 3 有问题
      

  5.   

    如果两个表是同等关系就用union all联接.
      

  6.   

    要看表与表的关系
    列关系:
    a join b on a.id=b.pid
    a left join b on a.id=b.pid
    a right join b on a.id=b.pid
    …………行连接:
    union all 有重复
    union 无重复我表述的不好,不准确,你可以到网上搜索