 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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
Select words from a text already in a MySQL table
Let us first create a table −
mysql> create table DemoTable1316 -> ( -> Value varchar(40) -> ); Query OK, 0 rows affected (0.47 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1316 values('MySQL'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable1316 values('Java'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable1316 values('MongoDB'); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable1316 values('C++'); Query OK, 1 row affected (0.13 sec) Display all records from the table using select statement −
mysql> select *from DemoTable1316;
This will produce the following output. These are the words we need to select later and find in a text −
+---------+ | Value | +---------+ | MySQL | | Java | | MongoDB | | C++ | +---------+ 4 rows in set (0.00 sec)
Following is the query to select words in the above table from the text “Deep Dive using Java is good for advanced knowledge, but not MySQL” −
mysql> select Value -> from DemoTable1316 -> where ( 'Deep Dive using Java is good for advanced knowledge, but not MySQL') like concat('%',Value,'%'); Output
+-------+ | Value | +-------+ | MySQL | | Java | +-------+ 2 rows in set (0.05 sec)
Advertisements
 