Skip to content

Instantly share code, notes, and snippets.

@quiznilo1
Created December 19, 2015 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quiznilo1/0c1ab7c8ae725000b281 to your computer and use it in GitHub Desktop.
Save quiznilo1/0c1ab7c8ae725000b281 to your computer and use it in GitHub Desktop.
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