質問編集履歴
2
テーブルにタイポがあったので修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,9 +24,9 @@
|
|
24
24
|
|
25
25
|
|8|13|aaa4|
|
26
26
|
|
27
|
-
|
|
27
|
+
|9|14|aaa5|
|
28
28
|
|
29
|
-
|
|
29
|
+
|10|14|zzz1|
|
30
30
|
|
31
31
|
|
32
32
|
|
1
実際に調べたクエリーを記載
test
CHANGED
File without changes
|
test
CHANGED
@@ -40,4 +40,48 @@
|
|
40
40
|
|
41
41
|
|
42
42
|
|
43
|
+
また、ネットで調べたりして試したクエリーは以下の通りです。
|
44
|
+
|
45
|
+
```PostgreSQL
|
46
|
+
|
47
|
+
SELECT
|
48
|
+
|
49
|
+
a.user_id
|
50
|
+
|
51
|
+
FROM
|
52
|
+
|
53
|
+
table AS a
|
54
|
+
|
55
|
+
WHERE
|
56
|
+
|
57
|
+
(a.code LIKE '%aaa%' OR a.code LIKE '%zzz%')
|
58
|
+
|
59
|
+
AND NOT EXISTS(
|
60
|
+
|
61
|
+
SELECT
|
62
|
+
|
63
|
+
*
|
64
|
+
|
65
|
+
FROM
|
66
|
+
|
67
|
+
table as b
|
68
|
+
|
69
|
+
WHERE
|
70
|
+
|
71
|
+
b.id = a.id
|
72
|
+
|
73
|
+
AND b.code NOT LIKE '%aaa%'
|
74
|
+
|
75
|
+
AND b.code NOT LIKE '%zzz%'
|
76
|
+
|
77
|
+
)
|
78
|
+
|
79
|
+
GROUP BY
|
80
|
+
|
81
|
+
a.user_id
|
82
|
+
|
83
|
+
```
|
84
|
+
|
85
|
+
|
86
|
+
|
43
87
|
よろしくお願いします。
|