merge two tables as columns in one table

  • [font="Verdana"]

    Hi,

    I have 2 tables as,

    table1 with columns a,b,c and table2 with columns x,y,z both the tables have the same number of records.

    can I merge columns of those 2 tables as 1 table so all the columns will show as a,b,c,x,y,z in tableX?

    nalaka[/font]

  • Yes.

    But how will you match the two tables?

    If you want a1, b1, c1, x1, y1 and z1 how can you ensure that so that you do not end up with

    a1, b1, c1, x45, y45 and z45?


    N 56°04'39.16"
    E 12°55'05.25"

  • [font="Verdana"]

    Hi Peter,

    No need to match 2 tables. If I want to match and join I can do it easily by joining two tables using relevant fields. I just need to show all the colums as 1 table without matching. Is there a easy way to do that.

    suppose in my table2 all the rows have the same record but can't match any field with table1.

    [/font]

  • Well then. Just do a JOIN.

    INSERT Target (PkCol, a, b, c, x, y, z)

    SELECT t1.PkCol, t1.a, t1.b, t1.c, t2.x, t2.y, t2.z

    FROM Source1 AS t1

    INNER JOIN Source2 AS t2 ON t2.PkCol = t1.PkCol


    N 56°04'39.16"
    E 12°55'05.25"

  • [font="Verdana"]

    Thanks Peter

    [/font]

  • Hi there,

    I have a similar goal expect I dont have a UID. I thought I could just do a select into via a db link but it doesn't like it...

    so a join is my only option? If so is there a easy way to create a UID?

    Cheers,

Viewing 6 posts - 1 through 5 (of 5 total)

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