包含“ The”的字符串的文本操作?在MySQL中
您可以使用ORDERBYTRIM()
。让我们首先创建一个表-
mysql> create table DemoTable -> ( -> Title text -> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('MongoDB is a no SQL database'); mysql> insert into DemoTable values('The MySQL is a relational database'); mysql> insert into DemoTable values('The Java language is good'); mysql> insert into DemoTable values('Python is good language');
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+----------------------------------+ | 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)
这是对包含“The”的字符串进行文本操作的查询-
mysql> select *from DemoTable -> order by trim(leading 'The ' from Title);
这将产生以下输出-
+----------------------------------+ | 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)