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
34 lines (31 loc) · 706 Bytes
/
query.sql
File metadata and controls
34 lines (31 loc) · 706 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
-- name: DeleteJoin :exec
DELETE jt.*,
pt.*
FROM
join_table as jt
JOIN primary_table as pt ON jt.primary_table_id = pt.id
WHERE
jt.id = ?
AND pt.user_id = ?;
-- name: DeleteLeftJoin :exec
DELETE jt.*,
pt.*
FROM
join_table as jt
LEFT JOIN primary_table as pt ON jt.primary_table_id = pt.id
WHERE
jt.id = ?
AND pt.user_id = ?;
-- name: DeleteRightJoin :exec
DELETE jt.*,
pt.*
FROM
join_table as jt
RIGHT JOIN primary_table as pt ON jt.primary_table_id = pt.id
WHERE
jt.id = ?
AND pt.user_id = ?;
-- name: DeleteJoinWithSubquery :exec
DELETE pt
FROM primary_table pt
JOIN (SELECT 1 as id) jt ON pt.id = jt.id;