How to insert into table from two tables of data?

  • Hi i am having three tables (EMPLOYEE,ADDRESS,QUALIFICATION).

    The below is table structure

    EMPLOYEE

    id

    name

    pg

    street

    city

    state

    pg

    ADDRESSstreet

    city

    state

    QUALIFICATIONug

    pg

    The above is table structures.

    I need to select values from address & qualification tables and insert the same into employee table by giving id and name values.

    Thanks

  • [font="Verdana"]I must say, you need to update the Employee table. Tell us which fields of Employee table you wants to update? By the way, how could you have same column name in one table? i.e. in Employee table 3rd and last column.

    EMPLOYEE

    id

    name

    pg

    street

    city

    state

    pg

    please specify more details.

    Mahesh[/font]

    MH-09-AM-8694

  • Hi sharma,

    Moreover there is no relationship between Employee table

    with Address/Qualification table.

    Tell me in which scenario you want the result set?

    ---

  • Sorry the column pg is entered as two times.

    This is a scenario

    Select the values from both tables and insert into employee table along with id and name.

    Any help?

  • [font="Verdana"]As the previous poster asked, mention the relation between employee and rest 2 tables.

    Mahesh[/font]

    MH-09-AM-8694

  • Hi Mahesh..

    There is no relationship between those tables.

    I am doing dumping from two tables into one table.

    Migrate data into one table.

    The above tbls are sample tbls..

  • If there's no relation between them (something like an employee ID), then there's no way to match the rows from one to the other. Is that what you're saying?

    - 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

  • [font="Verdana"]

    sharma (5/6/2008)


    Hi Mahesh..

    There is no relationship between those tables.

    I am doing dumping from two tables into one table.

    Migrate data into one table.

    The above tbls are sample tbls..

    Sharma, if there is no any relationship between either the tables, there is no way to do this in right manner. If you will try to update the Employee table without any relation, it will produce Cartesian product and will insert into Employee table.

    In that can you need to create relationship between these tables so that your data can migrate well.

    Mahesh

    [/font]

    MH-09-AM-8694

  • Yes GSquared.

    For initial data dumping i need to do that way only.

    I am having one table. But i need to fetch data from two tables and insert into one table

    Thanks

  • Does Employee table have any existing data?

  • Hello Sharma,

    there is no unique relationship between employee and two more tables,and then on which scenario can we insert into employee table?

  • sharma (5/6/2008)


    Yes GSquared.

    For initial data dumping i need to do that way only.

    I am having one table. But i need to fetch data from two tables and insert into one table

    Thanks

    Not inserting , it should be updating. for update the two table should have relational key with the main table

  • No.. Initially Employee tbl does not contain data

  • Since there's no relationship in the data, just insert from the first table, then insert from the second table.

    - 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

  • sharma (5/6/2008)


    Hi i am having three tables (EMPLOYEE,ADDRESS,QUALIFICATION).

    The below is table structure

    EMPLOYEE

    id

    name

    pg

    street

    city

    state

    pg

    ADDRESSstreet

    city

    state

    QUALIFICATIONug

    pg

    The above is table structures.

    I need to select values from address & qualification tables and insert the same into employee table by giving id and name values.

    Thanks

    if it is insert then from where you get employee id and name and is your ADDRESS and QUALIFICATION table have data in same order then create one column for id in both table and insert the records in employee table using join

Viewing 15 posts - 1 through 15 (of 23 total)

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