excel - Use id from parent table when importing child table in MySQL -




i have parent table, city, has 2 columns id , name in database, uploaded through '.csv' file, in format:

id | name
1 | karachi
2 | hyderabad

i have excel file has data in following format:

city | sector
karachi | jamshed town
karachi | gulshan 13-d
hyderabad| sarfaraz colony

i want import data of sectors columns city_id, sector city table , not city name. how can id parent table. (since data in thousands in couple of files don't prefer writing formulas in excel)

to honest, import city table excel , use vlookup() function map cities' id sectors , import sectors mysql after that.

the other solution create table in mysql has city name , sector fields, , import sectors dataset table. can use insert ... select ... statement populate original sector table city id , sector:

insert sector (city_id, sector) select id, sector city     inner join sector_with_c_name s2 on city.name=s2.city 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -