Reputation: 131
I have a table employee with thousands data. I need search particular string from this table. How to write query for that Please help me Thanks in advance
Upvotes: 0
Views: 240
Reputation: 1408
If one (or possibly more) column has a bulk text you can use full-text search ability of mysql (5.6 and above) to do that. It will speed up search operation very much. The Documentation is here.
Sample:
CREATE TABLE articles (
id INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
title VARCHAR(200),
body TEXT,
FULLTEXT (title,body)
) ENGINE=InnoDB;
SELECT id, title, body,
MATCH (title,body) AGAINST ('database' IN BOOLEAN MODE) AS score
FROM articles ORDER BY score DESC;
Upvotes: 0
Reputation: 1055
Here's an example
SELECT field_name
FROM table_name
WHERE = 'value'
Upvotes: 2