简体   繁体   中英

Mysql WHERE & MATCH AGAINST in same query

I'm currently working on a query in MYSQL where both the "WHERE" and "MATCH AGAINST" function are used to create the result. However when I try it out, I get error. Here is the Query:

foreach($db->query("SELECT * FROM Table WHERE Table.Column1 = '$Search1'
AND MATCH(Table.Column2) AGAINST ('$Search2' IN BOOLEAN MODE)") as $Question);

$db contacts the database.

Table is the table the query gets its information from from.

Column1 and Column2 are the specific columns that are used to match information to the user made input. Column1 contains a single number (ex 1234) and Column2 contains multible numbers (ex 12-02-11)

Search1 and Search2 are variables that are connected to the result from user made input ( <input type="text"> in HTML).

What I want to get out of this is only the result where both $Search1 and $Search2 are matched with information that exists in Table.

An exact match between Column1 and $Search1. As well as a match between column2 and Column2 (The error shows even when I type in the same numbers that already exist in Table(ex: column2 = "12-12-12" $Search2 = "12-12-12" and still error)).

How should I write my query?

Here is the full error message (keep in mind that I use other variables than those in the question):

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]: General error: 1191 Can't find FULLTEXT index matching the column list' in C:\\xampp\\htdocs\\BGS\\fragor\\Littraurval.php:87 Stack trace: #0 C:\\xampp\\htdocs\\BGS\\fragor\\Littraurval.php(87): PDO->query('SELECT * FROM m...') #1 {main} thrown in C:\\xampp\\htdocs\\BGS\\fragor\\Littraurval.php on line 87

Can't find FULLTEXT index matching the column list

Check you table schema for missing FULLTEXT index on column you search.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM