how to import data from a text file?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Tassadduq
Forum Commoner
Posts: 60
Joined: Wed Dec 03, 2008 2:53 pm

how to import data from a text file?

Post by Tassadduq »

i have two text file which contains countries and city names.
the structure of the files are as
country names =
total fields in the country names text files are 4.
1=cc_fips
2=cc_iso
3=tld
4=country_name
second text file contains the cities name of all the world.
total fields in the cities names are 2
1=cc_fips
2=city_name

i have created a database named "cityofcountries".
in the database i have two tables
1=countries
2=cities

the fields of the countries tables are
1=countryid
2=countryname
3=country_tld
4=country_cc_iso
5=country_cc_fips
and the fileds of the cities table are
1=cityid
2=cityname
3=city_cc_fips

now i want to import the countries data from countries name text file into countries table and cities name data from cities name text file into cities table.

so what will be the query?
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: how to import data from a text file?

Post by VladSun »

I don't know - you didn't mention the SQL engine you are using. MySQL, PGSQL, MSSQL ... etc.?
There are 10 types of people in this world, those who understand binary and those who don't
User avatar
Tassadduq
Forum Commoner
Posts: 60
Joined: Wed Dec 03, 2008 2:53 pm

Re: how to import data from a text file?

Post by Tassadduq »

i am using SQLyog Enterprise
Post Reply