PHPMYadmin table Migraton

50 views Asked by At

I need some help with a migration in phpmyadmin

I have 2 Tables with different stucture, I want that it automatically copy the NAME ADRESS LONGITUDE AND LATIDUDE from the [ store ] database to the [ tbl_storefinder_stores ] in the right row, but don't know how to do this.

enter image description here

3

There are 3 answers

12
Jeremy C. On BEST ANSWER

EDIT: the query you want to be running seems to be get all records from the 'store' table and insert them into tbl_storefinder_stores with the same values like this:

INSERT INTO tbl_storefinder_stores(store_name, store_address, lat, long)
            SELECT name, address, latitude, longitude
    from stores;

fiddle

If you want to create new records in the stores table for all of the records in the other table you can just do:

INSERT INTO stores(name, address, latitude, longtitude)
VALUES(
SELECT store_name, store_address, lat, long
from tbl_storefinder_stores
);

Or if you want to update the records in stores:

UPDATE stores
SET (name, address, latitude, longtitude)
= (select store_name, store_address, lat, long
   from tbl_storefinder_stores
   where tbl_storefinder_stores.field = stores.field) //field that is the same in both tables and won't change 

0
Savage L On

Maybe u can try this:

UPDATE table SET columnB = columnA

U can check the answer at here

Copy data into another table

0
Vhortex On
    UPDATE tbl_storefinder_stores
SET lat = (
    SELECT latitude
    FROM store
    WHERE <condition here> 
    LIMIT 1
)

Condition must reference one of tbl_storefinder_stores field