假设表 A有3列分别为a1,a2,a3  表B有b1,b2,b3
现在我用select a1 from A  取出a1的值,可能有多行,
而我要所查询出的每一行的a1值作为表B的查询条件(select * from B where b1>a1),应该怎么写?

解决方案 »

  1.   

    xie de hen bu qing chu.jia ru cha xun dao a1 wei 1,3,5na b1>1 hai shi b1>3 hai shi b1>5???
      

  2.   


    逻辑乱了,你这样做只能选出部分记录相当于select * from B where b1 > (select min(a1) from A)
      

  3.   


    我的意思就是从表A中查询出来的a1值都要作为表B的查询条件
      

  4.   

    这样
    select b.* from a,b where a.id = b.id and b.b1>a.a1
      

  5.   

    select a1,b.* from a,b where b1>a1
      

  6.   

    select * from B where b1>(select max(a1)from A)
      

  7.   

    问题是你只有1个b1>a1条件,如果2表没有关联字段的话,没必要循环,1条语句就出来了
      

  8.   

    感觉你的问题是不是条件结果集中a的值不唯一?那样的话用select distinct a1 from A