Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2008
    Posts
    16
    Plugin Contributions
    0

    Default phpmyadmin sql to copy table fields?

    I have some extra product info fields in a separate table and now wish to copy them to the main product info table and am nervous of making a mistake.

    Having backed up what is the most full proof method of adding and then copying the extra fields from one table to another using phpmyadmin? (really i'd like to know the correct syntax)

  2. #2
    Join Date
    Aug 2005
    Location
    Arizona
    Posts
    27,755
    Plugin Contributions
    9

    Default Re: phpmyadmin sql to copy table fields

    full proof method of adding and then copying the extra fields
    Adding tables or adding records to existing tables is only a small part

    What are you going to use for code to access/add to/display the data in these added fields??

    Make a backup and suggest that you create a test/development instal for this versus trying this on your operational install

    https://www.zen-cart.com/tutorials/i...p?article=103l
    Zen-Venom Get Bitten

  3. #3
    Join Date
    Oct 2008
    Posts
    16
    Plugin Contributions
    0

    Default Re: phpmyadmin sql to copy table fields?

    I've already got code to display the additional info in product info, product listing, basket, checkout, historic orders and in the admin (from another shop) but this was all based on storing the extra fields in the product table not in an 'extra stuff' table- so rather than doing a lot of re-writes I thought I'd go this route.

    Anyhow I've decided to make copies of the two tables and try the merge. I'll export the data before and after into excel and do a compare - then when I'm sure it's woking like I want I'll do it for real.

  4. #4
    Join Date
    Apr 2006
    Location
    London, UK
    Posts
    10,569
    Plugin Contributions
    25

    Default Re: phpmyadmin sql to copy table fields?

    You would have to extend the product table to add the new columns, and the extension table would need a unique index in common with the product table (probably products_id). Then you could do something like

    UPDATE products AS p, extension_table AS et
    SET p.column_name_1 = et.column_name_1,
    p.column_name_2 = et.column_name_2,
    ...
    p.column_name_n = et.column_name_n
    WHERE p.products_id = et.products_id;
    Kuroi Web Design and Development | Twitter

    (Questions answered in the forum only - so that any forum member can benefit - not by personal message)

  5. #5
    Join Date
    Oct 2008
    Posts
    16
    Plugin Contributions
    0

    Default Re: phpmyadmin sql to copy table fields?

    Many thanks Kuroi that was just what I was after ! Just done a test and seems OK. products_id was the index of course. This was what I used on the copies of the tables

    UPDATE zen_products1 AS p, zen_products_extra_stuff1 AS et
    SET p.products_ref = et.products_ref
    WHERE p.products_id = et.products_id;
    I've eyeballed the result and it looks fine but now I'm going to run do some more checks to makes sure it really is OK before doing the live run.

    Thanks again.


 

 

Similar Threads

  1. v139h Save the Multi Table Query Result in phpmyadmin or by SQL CLI
    By explorer1979 in forum General Questions
    Replies: 2
    Last Post: 31 Dec 2013, 09:03 PM
  2. Copy tax table from SQL database phpMyAdmin
    By giftmeister in forum General Questions
    Replies: 0
    Last Post: 31 Oct 2011, 07:57 PM
  3. Need help w/ SQL query in phpMyAdmin
    By audradh in forum General Questions
    Replies: 17
    Last Post: 16 Nov 2009, 01:05 PM
  4. How to use phpMyAdmin to get a copy of your raw dbase sql
    By schoolboy in forum General Questions
    Replies: 5
    Last Post: 12 Nov 2009, 08:31 AM
  5. Can I Copy Products & Attributes from another site in phpmyadmin?
    By milobloom in forum Upgrading from 1.3.x to 1.3.9
    Replies: 0
    Last Post: 13 May 2007, 06:00 PM

Posting Permissions

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