combine two tables without using join

  • Cadavre (2/3/2012)


    Narud (2/3/2012)


    To do this without joins, you can use this deprecated, but still useful sintaxis:

    SELECT a.*, b.*

    FROM Table1 a, Table2 b

    Best regards!

    Oh for the love of. . .

    1) That is still a join

    2) It doesn't produce the results that the OP wanted anyway

    Oops! My apologies, I didn't see the entire picture before put mi post.

    And certainly, your solution is pretty clever and elegant.

  • I'm not getting anything from that..can u explain it?

  • I'm not getting anything from that..can u explain it?

  • No i don't want to use joins at all..I just want to know whether its possible to combine?

  • It is possible to join without using Join.

    You can Union the tables and then Pivot them. It's a bad idea, takes a lot of work, and you need to already know your row-values before you run the query in order to do it, but it can be done.

    You can insert the results of a query of the first table into a temp table, and then use Update or Merge to put the results of the second table into columns in that temp table and then query that.

    You can use a cursor over one or both tables to generate a dynamic Table Values Construct, and query that.

    But ALL of those, and every other method you can think of for it, require that you first define the relationship between the tables, or accept a cartesian product (every row in table 1 joined to every row in table 2). And, all of those are more work than using Join. You can use them, but it's stupid to do so.

    You haven't answered yet why you don't want to use Join. It's a bad requirement, but you're insisting on it. So, use one of the above methods. They don't use Joins, they take more work than using Joins, they produce the same result as using Joins, they have more problems than using Joins, and they have no advantages over using Joins, but they fulfill your requirement that you can't use Joins.

    Honestly, that requirement is like asking how to drive a car without using a steering wheel. Yes, it can be done, but not well.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • Nothing like that i have used what u said like only..creating temporary table and using joins only..Thanks for ur help...I just want to know whether its possible or not..But i have got a clear view now, without joins we can't combine tables with less time and high performance.Thanks..

  • dinesh8804 (2/6/2012)


    Nothing like that i have used what u said like only..creating temporary table and using joins only..Thanks for ur help...I just want to know whether its possible or not..But i have got a clear view now, without joins we can't combine tables with less time and high performance.Thanks..

    You're welcome.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 7 posts - 16 through 21 (of 21 total)

You must be logged in to reply to this topic. Login to reply