Results 1 to 3 of 3

Thread: Update

  1. #1
    Join Date
    May 2013
    Posts
    33

    Unanswered: Update

    Hi All..
    I am new to MySQL database.....
    So here i am having doubt in UPDATE ....

    When using Oracle we can interchange rows from one column to another column. Example as follows:

    Code:
    SQL> select * from sample;
    
            ID     SALARY
    ---------- ----------
             1         10
             2         20
             3         30
             4         40
    
    SQL> update sample set id=salary, salary=id where id = id;
    
    4 rows updated.
    
    SQL> select * from sample;
    
            ID     SALARY
    ---------- ----------
            10          1
            20          2
            30          3
            40          4
    I need query for the same in Mysql...

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    I have previously written a tutorial explaining this. Try here MySQL – Update rows reversing column values IT Integrated Business Solutions
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    Join Date
    May 2013
    Posts
    33
    Thanks for the reply.

Posting Permissions

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