有三个表,分别是abc,从a表中查询出来的结果(结果唯一)做b表的查询条件,再用b表返回的结果(结果不唯一)做c表的查询条件,然后把查询结果全部显示DBGrid中,速度越快越好,如果不能实现该怎么做呀!!!

解决方案 »

  1.   

    select * from c where id=
    (selsect id from b where id=
      (select id from a where ...))如果是sqlserver把()去掉
      

  2.   

    有三个表,分别是abc,从a表中查询出来的结果(结果唯一)做b表的查询条件,再用b表返回的结果(结果不唯一)做c表的查询条件,然后把查询结果全部显示DBGrid中,速度越快越好,如果不能实现该怎么做呀!!!select c.field1 from c where id in (
      select b.field1 from b where id=(
        isNull((select top 1 a.field1 from a where id='xxx'),'')
      )
    )
      

  3.   

    --方式二,更快
    select c.field1 
    from c left join b on b.id=c.id
           left join a on b.id=a.id
    where a.id = 'xxx'
      

  4.   

    select c.f1 from c,b,a where a.f1=b.f1 and b.f2=c.f2
      

  5.   

    在表返回的值不唯一时最好用:in 代替 =
    select * from c where id in (selsect distinct id from b where id in (select distinct id from a where ...))
      

  6.   

    select * from c where id in
    (selsect id from b where id=
      (select id from a where ...))
      

  7.   

    Select * From c where id In(Select id From b 
    where id In(select id from a where......))
      

  8.   

    select c.field1 from c where id in (
      select b.field1 from b where id=(
        isNull((select top 1 a.field1 from a where id='xxx'),'')
      )
    )
      

  9.   

    那里错了???select * from wdst_admin.S_Song where songid in (
      select * from wdst_admin.S_Singersong where singerid in(
        (select * from wdst_admin.S_Singer where Singername='阿杜')
      )
    )服务器: 消息 116,级别 16,状态 1,行 1
    当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式。
    服务器: 消息 116,级别 16,状态 1,行 1
    当没有用 EXISTS 引入子查询时,在选择列表中只能指定一个表达式。
      

  10.   

    子查询请指定列select * from wdst_admin.S_Song where songid in (
      select singerid from wdst_admin.S_Singersong where singerid in(
        (select singerid from wdst_admin.S_Singer where Singername='阿杜')
      )
    )
      

  11.   

    服务器: 消息 208,级别 16,状态 1,行 1
    对象名 'wdst_admin.S_Song' 无效。
    服务器: 消息 208,级别 16,状态 1,行 1
    对象名 'wdst_admin.S_Singersong' 无效。
    服务器: 消息 208,级别 16,状态 1,行 1
    对象名 'wdst_admin.S_Singer' 无效。
    还是不对啊!!!
      

  12.   

    好多条语句了
    楼主你看看是不是你的数据库没选对阿?比如说选的master什么的