-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathqueries.sql
67 lines (64 loc) · 1.78 KB
/
queries.sql
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
60
61
62
63
64
65
66
67
SELECT *,
(select points
from users
where id = answers.created_by) as author_points
FROM "answers"
WHERE (question_id = 1)
SELECT
"questions".*,
string_agg("question_tags".tag_id, ', ') as tags,
(SELECT count(*)
FROM bookmarks
WHERE bookmarks.question_id = 6 AND user_id = 'admin@123') as bookmarks
FROM "questions"
inner join question_tags on question_tags.question_id = questions.id
WHERE ("questions".id = 1)
GROUP By 1;
insert into question_comments
(comment, author_id, question_id)
values
('test comment 1', 'admin@123', 1);
insert into question_comments
(comment, author_id, question_id)
values
('test comment 2', 'admin@123', 1);
insert into question_comments
(comment, author_id, question_id)
values
('test comment 3', 'admin@123', 1);
insert into question_comments
(comment, author_id, question_id)
values
('test comment 4', 'admin@123', 1);
insert into question_comments
(comment, author_id, question_id)
values
('test comment 5', 'admin@123', 1);
insert into question_comments
(comment, author_id, question_id)
values
('test comment 6', 'admin@123', 1);
insert into answer_comments
(comment, author_id, answer_id)
values
('test comment 1', 'admin@123', 1);
insert into answer_comments
(comment, author_id, answer_id)
values
('test comment 2', 'admin@123', 1);
insert into answer_comments
(comment, author_id, answer_id)
values
('test comment 3', 'admin@123', 1);
insert into answer_comments
(comment, author_id, answer_id)
values
('test comment 4', 'admin@123', 1);
insert into answer_comments
(comment, author_id, answer_id)
values
('test comment 5', 'admin@123', 1);
insert into answer_comments
(comment, author_id, answer_id)
values
('test comment 6', 'admin@123', 1);