Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2004
    Location
    Kuala Lumpur
    Posts
    38

    Unanswered: Insert Data From Inner Join Table

    Hi Expert,

    I have this query :-

    SELECT unt.aro_report
    FROM unit unt, facility fac
    WHERE unt.facility_id = fac.facility_id;


    From this query i want to insert unt.aro_report to facility table which have same facility id.

    If I run this :
    INSERT INTO facility
    (aro_report)
    SELECT unt.aro_report
    FROM unit unt, facility fac
    WHERE unt.facility_id = fac.facility_id;


    i'm not sure it will insert to right record whre facility id were equal.

    Please advise

    Shaffiq

  2. #2
    Join Date
    Dec 2007
    Posts
    253
    Quote Originally Posted by man_at_work22

    i'm not sure it will insert to right record whre facility id were equal.

    Please advise

    Shaffiq
    Test it and see.

  3. #3
    Join Date
    Jul 2008
    Location
    Ireland
    Posts
    11

    Should do

    Hi,

    Yeah this looks like it should work but the previous poster is right - testing is the only thing that will give you confirmation.

    You shouldnt be sticking new untested code into a production environment.

    Test, test, test and test again.

  4. #4
    Join Date
    Dec 2007
    Posts
    253
    Quote Originally Posted by GerardMcL_1
    Test, test, test and test again.
    You forgot about testing

  5. #5
    Join Date
    Jul 2008
    Posts
    5
    it will work.

  6. #6
    Join Date
    Mar 2007
    Posts
    623
    Quote Originally Posted by man_at_work22
    i'm not sure it will insert to right record whre facility id were equal
    What exactly do you mean by 'insert to right record'? Because inserting means creating new row; for updating a row you shall use update statement.
    The update success depends on the relationship between UNIT and FACILITY tables: if there would be more units belonging to one facility, it would not be possible.

    [Edit: Re-formulated the last sentence]

  7. #7
    Join Date
    Oct 2004
    Location
    Kuala Lumpur
    Posts
    38
    ooo stupid of me...it alla bout update not insert....thx evryone... thx flyboy....


    foolmyself

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •