用Access
表A:A1,A2,A3,A4
表B:B1,B2,B3,B4
表A与表B中A1=B1
表A中并不是所有数据都是A1=B1,也有部分数据A1<>B1
现要做一个统计,要求
A1=B1时 Select A1,A2,B2 As tempstr ...
A1=B1时 Select A1,A2,tempstr(等于A1) ...

解决方案 »

  1.   

    上面的错了
    用Access
    表A:A1,A2,A3,A4
    表B:B1,B2,B3,B4
    表A与表B中A1=B1
    表A中并不是所有数据都是A1=B1,也有部分数据A1<>B1
    现要做一个统计,要求
    A1=B1时 Select A1,A2,B2 As tempstr ...
    A1<>B1时 Select A1,A2,tempstr(等于A3) ...
      

  2.   

    1.select a1,a2,b2 as tempstr from A, B where a.a1=b.b12.select a1,a2,a3 as tempstr from a where a.a1 not in (select b1 from b)
      

  3.   

    hqhhh(枫叶)
    1:我是想在一个语句中实现
    2:select a1,a2,b2 as tempstr from A, B where a.a1=b.b1 (查不出任何数据)
    我用Select (Select B1 From 表B Where B1=A.A1), * From 表A (在ACCESS库中也查不出任何数据
    而表A和表B中的A1、B1大部分都是相等的)
      

  4.   

    语句应该可以这样写:
    Select (Select B2 From B Where B1=A.A1) As tempstr,
    IIF([tempstr]<>"" ,tempstr,A3) As Temp, * From A
    现在主要的问题是:Select (Select B2 From B Where B1=A.A1) As tempstr, * From A
    中的tempstr一直是空的,没有数据,而表A和表B中的A1、B1大部分都是相等的。
    不知道为什么会这样?