Skip to content

Instantly share code, notes, and snippets.

@vicapow
Last active December 14, 2015 21:18
Show Gist options
  • Select an option

  • Save vicapow/5149683 to your computer and use it in GitHub Desktop.

Select an option

Save vicapow/5149683 to your computer and use it in GitHub Desktop.
CREATE TABLE IF NOT EXISTS openclipart_issues(
clipart INTEGER NOT NULL
, reporter INTEGER DEFAULT NULL
, PRIMARY KEY(clipart, reporter)
, FOREIGN KEY(reporter) REFERENCES openclipart_users(id)
, FOREIGN KEY(clipart) REFERENCES openclipart_clipart(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB;
INSERT INTO openclipart_issues(clipart, reporter)
SELECT id, NULL
FROM ocal_files
WHERE upload_tags LIKE '%clipart_issue%';
-- ERROR 1452 (23000) at line 366: Cannot add or update a child row: a foreign key constraint fails (`ocal`.`openclipart_issues`, CONSTRAINT `openclipart_issues_ibfk_1` FOREIGN KEY (`reporter`) REFERENCES `openclipart_users` (`id`))
@vicapow

vicapow commented Mar 13, 2013

Copy link
Copy Markdown
Author

Cannot add or update a child row: a foreign key constraint fails (ocal.openclipart_issues, CONSTRAINT openclipart_issues_ibfk_1 FOREIGN KEY (clipart) REFERENCES openclipart_clipart (id))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment