-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsql_queries.txt
59 lines (45 loc) · 851 Bytes
/
sql_queries.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
## SETUP ##
#word table
CREATE TABLE words
(
word_id INT IDENTITY(1,1) PRIMARY KEY,
word VARCHAR(255),
learned BIT NOT NULL DEFAULT(0)
);
#environment table
CREATE TABLE environment
(
reading_id INT IDENTITY(1,1) PRIMARY KEY,
lux INT DEFAULT(0),
meets_target BIT NOT NULL DEFAULT(0)
);
## INSERTS / UPDATES ##
#insert word
INSERT INTO word (word_id, word, learned)
VALUES(wordID, word, 0);
#update word
UPDATE word
SET learned = 1
WHERE word_id = wordID;
#add reading
INSERT INTO environment (reading_id, lux, meets_target)
VALUES(readingID, lux, meetsTarget);
## QUERIES ##
#get word
SELECT *
FROM word
WHERE word_id = wordID;
#get all unlearned words
SELECT *
FROM word
WHERE learned = 0;
#get all learned words
SELECT *
FROM word
WHERE learned = 1;
#get all words
SELECT *
FROM word;
#get all readings
SELECT *
FROM environment;