Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Rookie Oracle SQL question

Options
  • 11-10-2006 9:58am
    #1
    Registered Users Posts: 23,212 ✭✭✭✭


    This is a tricky one to explain, so bear with me.

    I have two queries, A an B, both looking for the same data, under different conditions (so they have common columns). A is horrendous, B is relatively straight forward.

    What I want to do is combine the two of them into the one query, I was trying the following:

    SELECT * FROM

    ( <query A>) A,
    ( <query B>) B

    but what I am getting is the two result sets AND'ed together (as you would expect):

    A row 1 B row 1
    A row 2 B row 1
    ...
    A row n B row 1
    A row 1 B row 2
    A row 2 B row 2

    When in fact I want,

    A row 1
    A row 2
    ...
    A row n
    B row 1
    B row 2

    Am I completely off the mark on this one? Or is it staring me straight in the face?


Comments

  • Registered Users Posts: 4,188 ✭✭✭pH


    select ** query A **
    UNION
    select ** query B **


  • Registered Users Posts: 23,212 ✭✭✭✭Tom Dunne


    FFS, I didn't think it would be that easy. :)

    I have a tendancy to over-complicate things.

    Edit: Forgot to say thank you.


Advertisement