2016-08-03 17 views
0

我不能全文设置ft_min_word_len,因为我使用网络托管。
mysql匹配选择像标签,没有全文

DB领域
主题标签 - VARCHAR(256)/ utf8_general_ci

DB输入值例如
| #abc |
| #abc#123 |
| #123 |
| #abc#123 #abcd |
| #1234 | | #12345 |

我想搜索'#123'结果
| #abc#123 |
| #123 |
| #abc#123 #abcd |

PHP

$word = $mysqli->real_escape_string($_POST['word']); 
mysqli_query($mysqli, "... where (p.hashtag REGEXP '^(.*?(\\\b$word\\\b)[^$]*)$') ... "); 

我想比systax更多。

新增评论
DB输入值更详细
ID |标题|描述| hastag | viewCnt ...
1 | text1 | text0001 | #123 | 0
2 | text2 | text0002 | #123 #abc | 0
3 | text3 | text0003 | #12345 | 0
...

回答

0

您应该解决您的数据结构有一个表中正在使用的表每个哈希标签值和标识一行。

但在任何情况下,你可以做你想做使用的是什么like

select hashtag 
from db 
where concat(hashtag, '#') like concat('%', $search, '#%'); 
+0

的感谢!但没有工作。搜索结果0. – Integral

+0

@Integral。 。 。哎呀。我忽略了通配符。 –

+0

谢谢!我可以应用索引来实现性能吗? – Integral