
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Quickly search for a string in MySQL database?
Use FULLTEXT search to quickly search for a string. Let us first create a table −
mysql> create table DemoTable1554 -> ( -> Title text -> ); Query OK, 0 rows affected (0.63 sec)
Here is the query to create full text search −
mysql> create fulltext index faster_title on DemoTable1554(Title); Query OK, 0 rows affected, 1 warning (7.09 sec) Records: 0 Duplicates: 0 Warnings: 1
Insert some records in the table using insert command −
mysql> insert into DemoTable1554 values('John is working on MySQL database'); Query OK, 1 row affected (0.26 sec) mysql> insert into DemoTable1554 values('Adam Smith is working on Java language'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable1554 values('John smith is working on Python Language'); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1554;
This will produce the following output −
+------------------------------------------+ | Title | +------------------------------------------+ | John is working on MySQL database | | Adam Smith is working on Java language | | John smith is working on Python Language | +------------------------------------------+ 3 rows in set (0.00 sec)
Following is the query to quickly search for a string in a MySQL database. Here, we are searching for string “language” −
mysql> select * from DemoTable1554 where match(Title) against('language' in boolean mode);
This will produce the following output −
+------------------------------------------+ | Title | +------------------------------------------+ | Adam Smith is working on Java language | | John smith is working on Python Language | +------------------------------------------+ 2 rows in set (0.00 sec)
- Related Questions & Answers
- MySQL database field type for search query?
- Search for a string within text column in MySQL?
- Search for specific characters within a string with MySQL?
- How to search a MySQL table for a specific string?
- How to search for exact string in MySQL?
- How to search a column for an exact string in MySQL?
- How to quickly reverse a string in C++?
- How to find and replace string in MySQL database for a particular string only?
- How to search for the exact string value in MySQL?
- How to search for a string in JavaScript?
- How to search for a pattern in a Java string?
- How to search a string for a pattern in JavaScript?
- How to search for ^ character in a MySQL table?
- Search for text between delimiters in MySQL?
- Search for PHP array element containing string?
Advertisements