SELECT 查询的时候 WHERE的条件是A字段=(SELECT 另外的表查询的结果) 这个怎么写?还有就是查询A表中B字段 与 C表中的D字段的乘积, 怎么实现?

解决方案 »

  1.   

    selct b*c
    from a,c
    ....
      

  2.   

    select * from table_a where a.num exists(select b.num from table_b where a.num=b.num);select a.b*c.d from a,c where ...
      

  3.   

    selct b*d   --刚才写错了
    from a,c
    ...
    SELECT 查询的时候 WHERE的条件是A字段=(SELECT 另外的表查询的结果) 这个怎么写?
    --where a in (select ...)
      

  4.   

    使用IN或EXISTS:
    --EXAMPLE
    SQL> select part_no from part_cost where part_no in (select part_no from inventory_part where part_no='1C520 10357');PART_NO
    -------------------------
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 1035712 rows selectedSQL> select part_no from part_cost a where exists (select '1' from inventory_part b where a.part_no=b.part_no and b.part_no='1C520 10357');PART_NO
    -------------------------
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 10357
    1C520 1035712 rows selected