Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2003
    Posts
    16

    Unanswered: Subselect in "from" part of query

    Hi!

    I've discovered that you can place a subselect in the "from" part of a query in Oracle, and then join with it in the "where" part.

    For example:

    select p.name, o.status_name
    from products p,
    (select s.status_name, o.order_id,o.product_id
    from order o , status s where o.status_id=s.status_id) orders
    where o.product_id=p.product_id

    This is quite neat, you can get really elegant solutions to some of your queries this way.

    Currently I'm in the process of tuning one of these queries, and was wondering if anybody knows how Óracle goes about executing them.

    Does it create some kind of in-memeory table from the subselect, or is the sql simply rewritten, or something else?

    I'm using version 8.1.6

    Best regards,
    Mattias

  2. #2
    Join Date
    Nov 2002
    Location
    Desk, slightly south of keyboard
    Posts
    697
    Hi Mattias,

    This might point you in the right direction....

    http://www.billmagee.co.uk/oracle/sqltune/index.html

    HTH
    Bill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •