Created
December 19, 2015 20:57
-
-
Save quiznilo1/0c1ab7c8ae725000b281 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `Department` ( | |
`deptID` integer PRIMARY KEY AUTOINCREMENT NOT NULL, | |
`department` text NOT NULL | |
); | |
CREATE TABLE `Employee` ( | |
`empID` integer PRIMARY KEY AUTOINCREMENT NOT NULL, | |
`empName` text NOT NULL, | |
`empAge` integer NOT NULL, | |
`dept` integer NOT NULL, | |
FOREIGN KEY (`dept`) REFERENCES `Department` (`deptID`) | |
); | |
INSERT INTO "Department" VALUES (1, 'Accounting'); | |
INSERT INTO "Department" VALUES (2, 'Marketing'); | |
INSERT INTO "Department" VALUES (3, 'Janitorial'); | |
-- Actually works | |
INSERT INTO Employee (empName, empAge, dept) VALUES ("Frank", 28, (SELECT deptID FROM Department WHERE deptID=3)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment