はここに私のテーブル構造である:オートコンプリートボックスのタグを選択するにはどうすればよいですか?
// tags
+----+------------+----------------------------------+----------+----------+------------+
| id | name | description | related | used_num | date_time |
+----+------------+----------------------------------+----------+----------+------------+
| 1 | PHP | some explanations for PHP | 1 | 4234 | 1475028896 |
| 2 | SQL | some explanations for SQL | 2 | 734 | 1475048601 |
| 3 | jQuery | some explanations for jQuery | 3 | 434 | 1475068321 |
| 4 | MySQL | some explanations for MySQL | 2 | 657 | 1475068332 |
| 5 | JavaScript | some explanations for JavaScript | 3 | 3325 | 1475071430 |
| 6 | HTML | some explanations for HTML | 6 | 2133 | 1475077842 |
| 7 | postgresql | some explanations for postgresql | 2 | 43 | 1475077851 |
| 8 | script | some explanations for script | 8 | 3 | 1475077935 |
+----+------------+----------------------------------+----------+----------+------------+
は、今私は自分の名前の一部にタグベースを選択する必要があり、また、私は、すべての関連するタグを選択する必要があります。
列:scr
例について
。期待される出力:
+----+------------+----------------------------------+----------+----------+------------+
| 3 | jQuery | some explanations for jQuery | 3 | 434 | 1475068321 |
| 5 | JavaScript | some explanations for JavaScript | 3 | 3325 | 1475071430 |
| 8 | script | some explanations for script | 8 | 3 | 1475077935 |
+----+------------+----------------------------------+----------+----------+------------+
-- Noted that "jQuery" tag is selected because of its relation with "JavaScript" tag
文字列:ph
。期待される出力:
+----+------------+----------------------------------+----------+----------+------------+
| 1 | PHP | some explanations for PHP | 1 | 4234 | 1475028896 |
+----+------------+----------------------------------+----------+----------+------------+
文字列:ys
。予想される出力:
+----+------------+----------------------------------+----------+----------+------------+
| 2 | SQL | some explanations for SQL | 2 | 734 | 1475048601 |
| 4 | MySQL | some explanations for MySQL | 2 | 657 | 1475068332 |
| 7 | postgresql | some explanations for postgresql | 2 | 43 | 1475077851 |
+----+------------+----------------------------------+----------+----------+------------+
-- Noted that both "SQL" and "postgresql" are selected because of their relation with "MySQL" tag
私はそれをどのように行うことができますか?
実は私はこのようなことを行うことができます。
SELECT * FROM tags WHERE name LIKE %:str%
しかし、私のクエリはrelated
列をサポートしていません。
@Drew yeah私が知っている、これはあなたの推奨データベース設計ではありません。 –