#1
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    676
    Rep Power
    7

    Copy table -> altered table (Continued...)


    Howdy. The first half of my question was successfully answered in my past Copy table -> altered table post. The second half is to generate a number when doing this.

    The 2 images in my other thread show a BEFORE and AFTER. (Forum wouldn't let me upload them here, even after renamed.) The BEFORE shows the current table with data. The AFTER is what I am making. BEFORE has its last 11 columns to meerly hold 1 value. I am able to make the copy over of just the single column.

    Now, the AFTER table needs to hold a value in its 'BillTo' column in reference to the column the 'Cost' value had come from. Column 'Meals' in the BEFORE table should offer 'BillTo' in the AFTER table a value of 4.

    Any help is extremely appreciated. Thank you!
    Last edited by Triple_Nothing; September 24th, 2013 at 09:54 AM.
    He who knows not and knows not he knows not: he is a fool - shun him. He who knows not and knows he knows not: he is simple - teach him. He who knows and knows not he knows: he is asleep - wake him. He who knows and knows he knows: he is wise - follow him
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    676
    Rep Power
    7
    *shrugz* Found no answers across the net, so kinda manually did it. Just ran the following line 10 times on the initial table, 1 for each column. Then the column held value I wished to simply just copy.
    Code:
    UPDATE table_name SET `BilledTo` = 1 WHERE `column name` IS NOT NULL;
    Meerly adjusted the BilledTo 1 each time, and defined the next column in line to set a category number for. THEN I ran the INSERT INTO ... SELECT FROM ... to copy the values to my new, minimized table.
    He who knows not and knows not he knows not: he is a fool - shun him. He who knows not and knows he knows not: he is simple - teach him. He who knows and knows not he knows: he is asleep - wake him. He who knows and knows he knows: he is wise - follow him

IMN logo majestic logo threadwatch logo seochat tools logo