|
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]
|