Skip to content

Instantly share code, notes, and snippets.

@durango
Created July 23, 2013 07:09
Show Gist options
  • Select an option

  • Save durango/6060390 to your computer and use it in GitHub Desktop.

Select an option

Save durango/6060390 to your computer and use it in GitHub Desktop.
SET FOREIGN_KEY_CHECKS = 1;
DROP TABLE IF EXISTS `User3s`;
CREATE TABLE IF NOT EXISTS `User3s` (`username` VARCHAR(255), `id` INTEGER NOT NULL auto_increment , `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB;
DROP TABLE IF EXISTS `Task3s`;
CREATE TABLE IF NOT EXISTS `Task3s` (`title` VARCHAR(255), `id` INTEGER NOT NULL auto_increment , `createdAt` DATETIME NOT NULL, `updatedAt` DATETIME NOT NULL, `User3Id` INTEGER, PRIMARY KEY (`id`), FOREIGN KEY (`User3Id`) REFERENCES `User3s` (`id`) ON DELETE RESTRICT) ENGINE=InnoDB;
INSERT INTO `User3s` (`username`,`id`,`createdAt`,`updatedAt`) VALUES ('foo',NULL,'2013-07-23 06:55:35','2013-07-23 06:55:35');
INSERT INTO `Task3s` (`title`,`id`,`createdAt`,`updatedAt`,`User3Id`) VALUES ('task',NULL,'2013-07-23 06:55:35','2013-07-23 06:55:35',NULL);
SELECT * FROM `Task3s` WHERE `User3Id` = '1' AND `User3Id` = '1' LIMIT 1;
UPDATE `Task3s` SET `title`='task',`id`=1,`createdAt`='2013-07-23 06:55:35',`updatedAt`='2013-07-23 06:55:35',`User3Id`=1 WHERE `id`=1;
DELETE FROM `User3s` WHERE `id`=1 LIMIT 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment