有A B 2表  
结构如下   
           A表
           id int;
          str1 varcha2(30);
          str2 varcha2(30);
          str3 varcha2(30);          B表
           id int;
          aid int;          外键 关联A表主键
          str1 varcha2(30);
          str2 varcha2(30);
          str3 varcha2(30);
  
         A表数据如下
              1 test1 test2 test3
         B表数据如下
               1 1 test11   test22   test33
             2 1 test111  test222  test333
             3 1 test1111 test2222 tett3333
 
     求SQL  表头显示  test1 test2 test3       A表的这条记录
          里面的数据  test1 是 B表str1 的数据  
                       test2 是 B表str2 的数据
                       test2 是 B表str3 的数据

解决方案 »

  1.   

    用sql语句不好实现啊 ,建议用开发工具做处理,应该不难
      

  2.   


    --是不是这个意思?select a.str1 test1, a.str2 test2, a.str3 test3
      from tableA a, tableB b
     where a.test1 = b.test1
       and a.test2 = b.test2
       and a.test3 = b.test3;
      

  3.   

    select a.str1 test1, a.str2 test2, a.str3 test3
      from tableA a, tableB b
     where a.str1 = b.str1
       and a.str2 = b.str2
       and a.str3 = b.str3;
      

  4.   

    不是这个意思 
    我的意思是查A B2表 
    A表对应的字段内容在上面 B表对应的字段在下面
     换个说法就是能不能把A表里str1的值当值B表的别名 再和B表的数据同时显示出来
      

  5.   

    换个说法就是能不能把A表里str1的值当值B表对应字段的别名 再和B表的数据同时显示出来
      

  6.   

    OK拉 直接用UNION弄的 虽然没有预想的那么好至少也变通实现拉