CREATE TABLE IF NOT EXISTS `mytable` ( `id` int(11) NOT NULL, `parent_id` int(11) NOT NULL, `name` varchar(256) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `mytable` -- INSERT INTO `mytable` (`id`, `parent_id`, `name`) VALUES (1, 0, 'item 1'), (2, 1, 'item 2'), (3, 2, 'item 3');
And then run following script