Update current database table from other database table

Discussion in 'MySQL' started by Julian_lock, May 15, 2011.

  1. #1
    Hi everyone those give a helping hand

    Im a newbie and still learning the mysql scripting, here is my question.

    I need to update the live database from standalone which I have restore together with live database. where I need to use the data in all the same column to my live database column.

    example :
    backup database = a
    live database = b

    table consist of : itemcode, itemdesc, unit price, cost, selling

    I want the data from databse a column selling to be the exact same data on database b.

    Therefore both of the column will be the same,
    or by scpecify where clause.

    How am I write the script???
     
    Julian_lock, May 15, 2011 IP
  2. ntomsheck

    ntomsheck Peon

    Messages:
    87
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Assuming itemcode is the index, this is the SQL code you would use. BTW, this info is most likely readily available on google.

    UPDATE b,a SET b.itemdesc=a.itemdesc,b.unit price=a.unit price, b.cost=a.cost,b.selling=a.selling WHERE b.itemcode=a.itemcode;
     
    ntomsheck, May 15, 2011 IP
  3. Julian_lock

    Julian_lock Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    THANK YOU VERY MUCH.

    YES YOUR RIGHT, IT DID READILY ON GOOGLE BUT THERE R SOME I DONT UNDERSTAND FULLY THE USAGE SINCE THIS IS MY FIRST TIME ENCOUNTER SQL SYNTAX.
    NOW I UNDERSTAND HOW TO USE FROM OTHER DATABASE AND UPDATE THE CURRENTLY.

    Now if I want to insert multiple row into current table from other database is it <insert into databaseA.table where databaseB.table = 'p9999'> does this query will insert new row into databaseA table taken from databaseB table with the info = to p9999???

    Is there any way that update the data such as search for missing row and update/insert into the table???
     
    Julian_lock, May 16, 2011 IP