Skip to content

Instantly share code, notes, and snippets.

@quiznilo1
Created Dec 19, 2015
Embed
What would you like to do?
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