問題:SQL搜索查詢
我想在我的SQL搜索查詢使用全文索引,但由於某種原因,它不從數據庫返回的任何職位。
PHP/SQL代碼:
$string = mysql_real_escape_string($_POST['searchtext']);
$query = "SELECT
EID,
CONCAT (u1.Firstname, ' ', u1.Lastname) AS Examiner,
Supervisor,
ExaminationDate,
FirstAuthor,
SecondAuthor,
Level,
Credits,
Completed
FROM betyg_essays grade
INNER JOIN betyg_users u1 ON grade.Examiner = u1.UID
WHERE
MATCH (Supervisor, FirstAuthor, SecondAuthor) AGAINST ('$string')
ORDER BY
EID ASC
";
MySQL表定義:
列數據庫有兩個職位:
場景:
如果我只搜索「每」它應該返回的第二個職位。
你能提供該表的DDL?你是如何指定全文索引的? – acme
以百分比符號圍繞搜索詞嗎? –
你現在很容易[sql注入](http://en.wikipedia.org/wiki/SQL_injection)!逃避你的輸入,和/或開始使用PDO或Mysqli! – Bono