
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Text Manipulation of Strings Containing 'the' in MySQL
You can use ORDER BY TRIM(). Let us first create a table −
mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (1.09 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('MongoDB is a no SQL database'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('The MySQL is a relational database'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('The Java language is good'); Query OK, 1 row affected (0.35 sec) mysql> insert into DemoTable values('Python is good language'); Query OK, 1 row affected (0.17 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+----------------------------------+ | Title | +----------------------------------+ | MongoDB is a no SQL database | |The MySQL is a relational database| | The Java language is good | | Python is good language | +----------------------------------+ 4 rows in set (0.00 sec)
Here is the query for text manipulation of strings containing “The ” −
mysql> select *from DemoTable -> order by trim(leading 'The ' from Title);
This will produce the following output −
+----------------------------------+ | Title | +----------------------------------+ | The Java language is good | | MongoDB is a no SQL database | |The MySQL is a relational database| | Python is good language | +----------------------------------+ 4 rows in set (0.00 sec)
Advertisements