0

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

Fawwad
  • 131
  • 1
  • 5

2 Answers2

2

Here's an example

SELECT field_name 
FROM table_name 
WHERE = 'value'
shA.t
  • 16,580
  • 5
  • 54
  • 111
Melchizedek
  • 1,057
  • 17
  • 29
0

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;
Mostafa Vatanpour
  • 1,328
  • 13
  • 18