forked from sqlc-dev/sqlc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.sql
More file actions
41 lines (38 loc) · 646 Bytes
/
query.sql
File metadata and controls
41 lines (38 loc) · 646 Bytes
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
-- Example queries for sqlc
CREATE TABLE authors (
id integer PRIMARY KEY,
name text NOT NULL,
age integer
);
CREATE TABLE translators (
id integer PRIMARY KEY,
name text NOT NULL,
age integer
);
CREATE TABLE books (
id integer PRIMARY KEY,
author text NOT NULL,
translator text NOT NULL,
year integer
);
-- name: DeleteAuthor :exec
DELETE FROM
books AS b
WHERE
b.author NOT IN (
SELECT
a.name
FROM
authors a
WHERE
a.age >= ?
)
AND b.translator NOT IN (
SELECT
t.name
FROM
translators t
WHERE
t.age >= ?
)
AND b.year <= ?;