If i’ve the following database table my_table (id,year,event)
CREATE TABLE `my_table` (
`id` int(3) NOT NULL auto_increment,
`year` text,
`event` text,
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
Now i would like to import some data inside this database my_table from text file with the following exact text example.
2011|Italy hosts the 68th Venice International Film Festival<br>
2011|Severe damage occurs as wildfires sweep through Oklahoma<br>
2010|In Sudan Liberation Army will demobilize child soldiers<br>
Can be done manually but for millions of events, it is impossible so i’ve been thinking to use another solution where it can depends on | To separate the year from the event then insert it into database where it stopped at <br> to roll another insertion after.
Any idea how can it be done, this would save months if done manually and also will teach important idea using php solutions ~Thanks
results i think should be
CREATE TABLE `my_table` (
`id` int(3) NOT NULL auto_increment,
`year` text,
`event` text,
PRIMARY KEY (`id`),
KEY `id` (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
INSERT INTO `my_table` VALUES (1, '2011', 'Italy hosts the 68th Venice International Film Festival');
INSERT INTO `my_table` VALUES (2, '2011', 'Severe damage occurs as wildfires sweep through Oklahoma');
INSERT INTO `my_table` VALUES (3, '2010', 'In Sudan Liberation Army will demobilize child soldiers');
Read up on LOAD DATA INFILE. It allows you to specify separators (
|) and line terminators (<br>\n).