#1
  1. No Profile Picture
    Super Moderator
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,170
    Rep Power
    22

    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 10:54 AM.
    He who knows not that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.
  2. #2
  3. No Profile Picture
    Super Moderator
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2009
    Location
    Hartford, WI
    Posts
    1,170
    Rep Power
    22
    *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 that he knows not is a fool, ignore him. He who knows that he knows not is ignorant, teach him. He who knows not that he knows is asleep, awaken him. He who knows that he knows is a leader, follow him.

IMN logo majestic logo threadwatch logo seochat tools logo