In order to retrive field name from the table that matches the search criteria, just do run the following query.
SELECT *, MATCH(Field name 1) AGAINST ('*searchable value*' in boolean mode) as label1,
MATCH(Field name 2) AGAINST ('*searchable value*') as label2, ... FROM table_name
WHERE MATCH(Field name 1, Field name 2, ...) AGAINST ('*searchable value*')
Ex:
SELECT *, MATCH(customers_firstname) AGAINST ('*suresh*') as firstname,
MATCH(customers_lastname) AGAINST ('*suresh*') as lastname,
MATCH(customers_email_address) AGAINST ('*suresh*') as email_address
FROM customers
WHERE MATCH(customers_firstname, customers_lastname,
customers_email_address) AGAINST ('*suresh*').
if you dont want to include in boolean mode then alter the table with index type of "full text". and do the same thing excluding in boolean mode
No comments:
Post a Comment