1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Join two Sql queries horizontally(side by side) with no column in common

Discussion in 'General' started by sharo, Dec 10, 2010.

  1. sharo

    sharo Active Member

    Messages:
    6
    Likes Received:
    1
    Trophy Points:
    65
    I need to join the results of two queries horizontally. Consider a query below which will return two rows: Select * from Salary where sal>10000

    The result of the query above should be joined side by side with the result of the query below which will again return two rows.Or I need to just concatenate the two result sets:

    (Select 'xyz' from dual union Select 'abc' from dual)

    Please suggest how this can be done as I tried to do this with the query below but it returns a cartesian product:

    Select * from ( Select * from salary where sal>10000) TEMP1, (Select 'xyz' from dual union Select 'abc' from dual) TEMP2
     
    nazaruddin likes this.
  2. zargon

    zargon Community Moderator Forum Guru

    Messages:
    2,347
    Likes Received:
    348
    Trophy Points:
    1,430
    Location:
    Aurora, CO
    You have used nothing as a join predicate; you can get nothing else except a cartesian product. Since you haven't posted any data from this salary table no one can provide any assistance to you. Post some sample records from the salary table, including column headers (or post the table definition) so we can all have the same points of reference.