1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to copy data from one column to another in same table

Discussion in 'MySQL' started by FutureKing, Mar 21, 2013.

  1. #1
    Hi,
    I have a table

    [​IMG]

    Now I want to copy all bill_id values to bill_folder column.
    I tried following command but it didn't worked. It just returned "0 row(s) affected"

    UPDATE bills
    SET bill_folder = bill_id

    Please help
    FutureKing, Mar 21, 2013 IP
  2. merlin77

    merlin77 Active Member

    Messages:
    54
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    78
    #2
    Try it like this
    UPDATE `bills` SET bill_folder=bill_id
    merlin77, Mar 21, 2013 IP
  3. FutureKing

    FutureKing Active Member

    Messages:
    182
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    Digital Goods:
    2
    #3
    Nope! It didn't worked.
    FutureKing, Mar 21, 2013 IP
  4. merlin77

    merlin77 Active Member

    Messages:
    54
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    78
    #4
    Ooops...forgot the other quotes -
    UPDATE `bills` SET `bill_folder` = `bill_id`;

    Don't forget the semi-colon at the end too!
    merlin77, Mar 21, 2013 IP
  5. FutureKing

    FutureKing Active Member

    Messages:
    182
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    Digital Goods:
    2
    #5
    Still didn't worked.
    FutureKing, Mar 21, 2013 IP
  6. jestep

    jestep Notable Member Premium Member

    Messages:
    3,486
    Likes Received:
    199
    Best Answers:
    16
    Trophy Points:
    280
    #6
    All of these examples should work. There's got to be something else going on here. You're updating from command line?
    jestep, Mar 21, 2013 IP
  7. merlin77

    merlin77 Active Member

    Messages:
    54
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    78
    #7
    My thinking also. I'm even trying to replicate it locally and it works for me.
    merlin77, Mar 21, 2013 IP
  8. FutureKing

    FutureKing Active Member

    Messages:
    182
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    Digital Goods:
    2
    #8
    No I am using SqlYog Enterprise.
    FutureKing, Mar 21, 2013 IP
  9. FutureKing

    FutureKing Active Member

    Messages:
    182
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    Digital Goods:
    2
    #9
    Ok! This time it worked!
    FutureKing, Mar 21, 2013 IP
  10. FutureKing

    FutureKing Active Member

    Messages:
    182
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    75
    Digital Goods:
    2
    #10
    Thank you everybody for your help. The problem was SQLYog was not updating its interface with new data. That's why I was seeing blank in bill_folder column
    FutureKing, Mar 21, 2013 IP
  11. jestep

    jestep Notable Member Premium Member

    Messages:
    3,486
    Likes Received:
    199
    Best Answers:
    16
    Trophy Points:
    280
    #11
    Yeah. Most DB GUI's make you refresh the table results before you can see the changes. Navicat works this way as well.
    jestep, Mar 21, 2013 IP
  12. merlin77

    merlin77 Active Member

    Messages:
    54
    Likes Received:
    3
    Best Answers:
    2
    Trophy Points:
    78
    #12
    Glad you got it fixed.
    merlin77, Mar 21, 2013 IP