Results 1 to 4 of 4

Thread: mysql update column with another column

  1. #1
    Join Date
    Apr 2009
    Posts
    24

    Post mysql update column with another column

    I need MySQL instruction for copying/update-split with another column the data in the same line for several lines in a table.

    If in first column data is 23, 56, 89 & column two is empty like below....

    Orignal
    row1 column1(23) : row2 column2();
    row1 column1(56) : row2 column2();
    row1 column1(89) : row2 column2();

    Should Look like
    row1 column1(23) : row2 column2(23);
    row1 column1(56) : row2 column2(56);
    row1 column1(89) : row2 column2(89);

  2. #2
    Join Date
    Apr 2008
    Posts
    2,005

    Re: mysql update column with another column

    If you generate a stateCountryTable that has two fields for the preservation of the country and the only condition you can use the SQL below to accomplish that you are talking but to update the same table should I'm not sure how that will be solved. However, you may enter them all to select from this table with the stuff analyzed and duplicated in a table where you have two fields, one for the condition and one for the country.

    INSERT INTO stateCountryTable SELECT SUBSTRING(OriginalFieldName,1,2) as country,SUBSTRING(CategoryName,4,2) as state FROM originalTable;

    as descriptive above, alternative you can copy you the table structure to give you a new name, delete you the existing country State range in the new table, only one structure without data therein. Then an inquiry like above, but enumerate all fields out and can do it in the order of the fields in the new table.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    Re: mysql update column with another column

    Update column in a table whose values are not found in another table.

    UPDATE TABLE_1 LEFT JOIN TABLE_2 ON TABLE_1.COLUMN_1= TABLE_2.COLUMN_2
    SET TABLE_1.COLUMN = EXPR WHERE TABLE_2.COLUMN2 IS NULL

    An outer joins is made based on the state of equijoin. Entries that do not match the equijoin from table2 are marked with the position of minimum signal.

    This facilitates the actualization Tabelle1 column with expression, whose appropriate value from Tabelle2 is returned as ZERO

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: mysql update column with another column

    It is not necessary loop by the means of the table, the development colonne2 = column1 references of the line which is currently in the course of treatment by selecting your declaration.

    UPDATE <TABLE> SET Column2 = Column1

    Just use update <your_table> set column2 = column1. That will place the values in column 1 into column 2.

Similar Threads

  1. Find The Value of one column in another column
    By Charth in forum Windows Software
    Replies: 3
    Last Post: 23-02-2011, 03:01 AM
  2. Replies: 3
    Last Post: 09-12-2009, 01:11 PM
  3. Mysql error message "Unknown column in on clause"
    By Carnie in forum Software Development
    Replies: 3
    Last Post: 21-11-2009, 11:03 AM
  4. MySQL Error: BLOB/TEXT Column Used in Key Specification
    By Balgovind in forum Software Development
    Replies: 4
    Last Post: 23-05-2009, 09:59 AM
  5. Getting the MAX value from a column
    By rupak in forum Software Development
    Replies: 4
    Last Post: 31-01-2009, 11:36 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,483,535.67748 seconds with 17 queries