You are here: importing a CSV file into two Mysql tables « PHP SQL « IT news, forums, messages
importing a CSV file into two Mysql tables

Posted by laredotornado on 11/02/05 16:30

Hi, I was wondering how, using MySQL and PHP 4 (if necessary), could I
import a single CSV file to populate two MySQL tables. The tables are

CREATE TABLE MANUFACTURERS (
`MANUFACTURER_ID` int(10) unsigned NOT NULL auto_increment,
`NAME` varchar(64) NOT NULL default '',
PRIMARY KEY (`MANUFACTURER_ID`)
) TYPE=InnoDB AUTO_INCREMENT=3 ;

CREATE TABLE `PRINTERS` (
`PRINTER_ID` int(11) NOT NULL auto_increment,
`MANUFACTURER_ID` int(10) unsigned NOT NULL default '0',
`NAME` varchar(64) NOT NULL default '',
PRIMARY KEY (`PRINTER_ID`),
KEY `PRINTERS_IDX1` (`MANUFACTURER_ID`)
) TYPE = INNODB AUTO_INCREMENT=35;

ALTER TABLE `PRINTERS`
ADD CONSTRAINT `FK_PRINTERS` FOREIGN KEY (`MANUFACTURER_ID`)
REFERENCES `MANUFACTURERS` (`MANUFACTURER_ID`) ON DELETE CASCADE;

The CSV file has 2 columns

Manufacturer_Name,Printer_Name

I've seen a mysql import command when there's just one table and I'm
hoping there is a slight variation for two.

Thanks, - Dave

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация