Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Rookie Oracle SQL question

  • 11-10-2006 08:58AM
    #1
    Registered Users, Registered Users 2 Posts: 23,202 ✭✭✭✭


    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, Registered Users 2 Posts: 4,188 ✭✭✭pH


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


  • Registered Users, Registered Users 2 Posts: 23,202 ✭✭✭✭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