表1:A
     aid      name
     1        上衣
     2        裤子表2:B
     bid      fid
     7        1
     8        2
     9        1
     10       2表3:C
     cid      fid
     20       7
     23       8
     24       9
     25       10若已知A表中的name字段是'上衣',要得到结果:
cid
20
23

解决方案 »

  1.   

    得到结果应该是:cid
                    20
                    24
      

  2.   

    select  cid from C where fid in( select bid from B where fid =(select aid from A where name='上衣'))
      

  3.   

    select c.cid from a inner join b on a.aid=b.fid
    inner join c on b.bid=c.id
    where a.name='上衣'
      
    *****************************************************************************
    欢迎使用CSDN论坛阅读器 : CSDN Reader(附全部源代码) 
    http://www.cnblogs.com/feiyun0112/archive/2006/09/20/509783.html
      

  4.   

    select * from c where fid in(select bid from a,b where a.aid=b.fid)
      

  5.   

    B 表的 fid 是不是写错了?   应该是aid吧  呵呵  表关系   用SQL 的查询做 very easy 吧