2013-03-15 52 views
0

我正在和CONTAINS一起工作,但它並不是在MySQL中工作。CONTAINS不能在mysql中工作

mysql> SELECT * FROM MUTHU; 
+---------------------+ 
| MY     | 
+---------------------+ 
| how is your studies | 
| how are you there | 
| hi there   | 
+---------------------+ 
3 rows in set (0.00 sec) 
mysql> SELECT * FROM MUTHU CONTAINS (MY, "how"); 
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 '(MY, 
"how")' at line 1 
+0

是'CONTAINS'甚至是一個真正的MySQL函數,在他們的文檔中我找不到它。 :S – Seer 2013-03-15 15:30:16

回答

0

你錯過了Where條件,

試試這個:

SELECT * FROM MUTHU 
Where MY CONTAINS (MY,"how"); 
+0

添加無法使用的地方。但INSTR的作品。 – 2013-03-15 17:45:26

+0

但是我想查詢select * from MUTHU 其中INSTR(MY,'how'或'hello');有什麼辦法嗎? – 2013-03-15 17:46:27

1

我不認爲MySQL有一個叫CONTAINS功能,請嘗試以下查詢:

SELECT * FROM MUTHU 
WHERE MY LIKE '%how%'; 
+0

http://stackoverflow.com/questions/3213998/performance-of-like-query-vs-full-text-search-contains-query – jcho360 2013-03-15 15:43:18

+1

Mysql有關鍵字CONTAINS。請編輯你的答案。 – AbhimanyuAryan 2015-03-10 00:53:13

+1

@AbhimanyuAryan請你告訴我'CONTAINS'關鍵詞的文檔在哪裏? – 2016-12-23 16:20:44

0

我相信包含主要用在Xpath/Xquery中。在mysql中類似的功能是INSTR()。正確的代碼是這樣使用的:

select * from MUTHU 
    where INSTR(MY, 'how') > 0; 
+0

@EAGER_STUDENT在回答您的問題時,答案是您必須兩次致電INSTR。如下所示:INSTR(MY,'how')> 0)或(INSTR(MY,'hello')> 0); – hillmandj 2013-03-15 18:20:55

相關問題