How do I replace field values with values in sql file

Discussion in 'MySQL' started by redtrak, Sep 4, 2008.

  1. #1
    I have a table that has default 0's for 'value1' and 'value2'.
    `tableA` ('id', 'stringB', 'value1', 'value2', 'stringB')
    (1, 'randtxt', 0, 0, 'randtxt'),
    (2, 'randtxt', 0, 0, 'randtxt'),
    (7, 'randtxt', 0, 0, 'randtxt');

    I have a sql file with the folling structure.
    INSERT INTO `tableA` ('id', 'value1', 'value2') VALUES
    (1, 500, 474),
    (2, 7763, 56754),
    (7, 4554, 1690);

    What is the correct structure for replacing the values of 'value1' and 'value2', but leave 'stringA' and 'stringB' alone?
     
    redtrak, Sep 4, 2008 IP
  2. vasago

    vasago Peon

    Messages:
    95
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    UPDATE tableA SET value1 = 500, value2 = 474;

    this is the general syntax.
    probably you would need a WHERE clause too to limit the rows which need to be updated.
    and if you need to update each row with different value, you'd need some more complicated query...
     
    vasago, Sep 5, 2008 IP
  3. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #3
    First you need to import your sql file into MySQL then do as vasago said.
     
    mwasif, Sep 6, 2008 IP