Hi I want to do this:
This is my table player_depotitems
CREATE TABLE `player_depotitems` (
`player_id` int(11) NOT NULL,
`sid` int(11) NOT NULL COMMENT 'any given range, eg. 0-100 is reserved for depot lockers and all above 100 will be normal items inside depots',
`pid` int(11) NOT NULL DEFAULT '0',
`itemtype` int(11) NOT NULL,
`count` int(11) NOT NULL DEFAULT '0',
`attributes` blob NOT NULL,
UNIQUE KEY `player_id_2` (`player_id`,`sid`),
KEY `player_id` (`player_id`),
CONSTRAINT `player_depotitems_ibfk_1` FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
And this is my marketoffers table:
CREATE TABLE `market_offers` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`world_id` tinyint(4) unsigned NOT NULL DEFAULT '0',
`player_id` int(11) NOT NULL,
`sale` tinyint(1) NOT NULL DEFAULT '0',
`itemtype` int(10) unsigned NOT NULL,
`amount` smallint(5) unsigned NOT NULL,
`created` bigint(20) unsigned NOT NULL,
`anonymous` tinyint(1) NOT NULL DEFAULT '0',
`price` int(10) unsigned NOT NULL DEFAULT '0',
`attributes` blob NOT NULL,
PRIMARY KEY (`id`),
KEY `sale` (`sale`,`itemtype`),
KEY `created` (`created`),
KEY `player_id` (`player_id`),
CONSTRAINT `market_offers_ibfk_1` FOREIGN KEY (`player_id`) REFERENCES `players` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8
I tried this query:
INSERT INTO market_offers(attributes) SELECT attributes FROM player_depotitems WHERE player_id = 232 AND itemtype = 2417
But I recived this error:
1452 - Cannot add or update a child row: a foreign key constraint fails (`poraserver`.`market_offers`, CONSTRAINT `market_offers_ibfk_1` FOREIGN KEY (`player_id`) REFERENCES
`players` (`id`) ON DELETE CASCADE)
Sorry if it is stupid question, but I'm realy newbie.
Edited 1 time(s). Last edit at 03/22/2013 12:56PM by aafd dfad.