質問編集履歴
1
中間テーブルを用いたタグ検索のSQL文とそれに伴うエラーを追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -45,3 +45,47 @@
|
|
45
45
|
|
46
46
|
|
47
47
|
どうかご享受お願いします。
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
※追記
|
54
|
+
|
55
|
+
tag_map(中間テーブル)
|
56
|
+
|
57
|
+
|id|zatu_id|tag_id|
|
58
|
+
|
59
|
+
|:--|:--:|--:|
|
60
|
+
|
61
|
+
|1|2|1|
|
62
|
+
|
63
|
+
|2|1|2|
|
64
|
+
|
65
|
+
|3|4|3|
|
66
|
+
|
67
|
+
|4|3|4|
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
**実行SQL**
|
72
|
+
|
73
|
+
SELECT * FROM zatu
|
74
|
+
|
75
|
+
WHERE EXISTS (
|
76
|
+
|
77
|
+
SELECT group_concat(tag_tmp.name) AS tags
|
78
|
+
|
79
|
+
FROM tag AS tag_tmp
|
80
|
+
|
81
|
+
JOIN tag_map AS itt ON tag_tmp.id = itt.tag_id
|
82
|
+
|
83
|
+
WHERE zatu.t_id = itt.zatu_id
|
84
|
+
|
85
|
+
HAVING FIND_IN_SET('tag1', tags)
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
エラー
|
90
|
+
|
91
|
+
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 7
|