2010-03-04 53 views
2

我想在我的PHP站點中整合MySQL全文搜索功能。MySQL:如何進行多表全文搜索

我現在有以下問題。

SELECT * 
FROM testtable t1, testtable2 t2 
WHERE MATCH (
t1.firstName, t1.lastName, t1.details, t2.firstName, t2.lastName, t2.details 
) 
AGAINST (
'founder' 
); 

和我有錯誤代碼:

#1210 - Incorrect arguments to MATCH 

你知道爲什麼和如何解決呢?

非常感謝!

編輯:

我採用RageZ的方法:

SELECT * 
FROM testtable t1, testtable2 t2 
WHERE MATCH (
t1.firstName, t1.lastName, t1.details 
) 
AGAINST (
'founder' 
) OR MATCH(t2.firstName, t2.lastName, t2.details) AGAINST (
'founder' 
); 

而且我有一個新的問題。如果我想找到的內容是:

AGAINST('founder', 'initiator', 'employee'); 

如何編寫查詢?

好的,我知道反對只能有一個標準。

AGAINST('founder'); 

回答

2

我想既然全文檢索使用,你應該分開表中的一些具體指標由OR

SELECT * 
FROM testtable t1, testtable2 t2 
WHERE MATCH (
t1.firstName, t1.lastName, t1.details 
) 
AGAINST (
'founder' 
) OR MATCH(t2.firstName, t2.lastName, t2.details) AGAINST (
'founder' 
); 
+0

產品給我(但後來,我沒有經驗與「匹配/反對」)..不應該有一個「限制」(又名加入),以防止這種情況? – lexu 2010-03-04 10:23:34

+0

@感謝RageZ,如果反對的內容是多個,那該如何處理? – 2010-03-04 10:27:36

+0

你將不得不復制模式多次 – RageZ 2010-03-04 10:58:28

0
AGAINST('founder initiator employee'); 

,或者您可以使用boolean mode與聞起來像笛卡爾更多的好東西