There is one table. Parent_id references same table id. How insert raw if parent_id = id? I don't know id(before insert) and could't insert if there is not parent_id. What the optimal way without getting last INCREMENT id and creating temporary table?
CREATE TABLE `test` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`parent_id` int(11) unsigned NOT NULL,
`someotherfield` varchar(45) NOT NULL,
PRIMARY KEY (`id`),
FOREIGN KEY `constr_catalog_guid_id` (`parent_id`) REFERENCES `test` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
This is not work:
Insert into 'test' values (parent_id = test.id, "NOt matter");