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 Well-Known Member

    Messages:
    193
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    125
    Digital Goods:
    4
    #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 Well-Known Member

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

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #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 Well-Known Member

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

    FutureKing Well-Known Member

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

    FutureKing Well-Known Member

    Messages:
    193
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    125
    Digital Goods:
    4
    #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 Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #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