MySQL 中包含"The "的字符串的文本操作
mysqlmysqli database更新于 2024/1/30 13:21:00
您可以使用 ORDER BY TRIM()。让我们首先创建一个表 −
mysql> create table DemoTable -> ( -> Title text -> ); Query OK, 0 rows affected (1.09 sec)
使用 insert 命令在表中插入一些记录 −
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)
使用 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)