在单个MySQL查询中实现SELECT LIKE和CHAR_LENGTH()
让我们首先创建一个表-
mysql> create table DemoTable-> (
-> Name varchar(20)
-> );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values('Chris Brown');mysql> insert into DemoTable values('Adam Smith');
mysql> insert into DemoTable values('John Smith');
mysql> insert into DemoTable values('Carol Smith');
使用select语句显示表中的所有记录-
mysql> select * from DemoTable;
这将产生以下输出-
+-------------+| Name |
+-------------+
| Chris Brown |
| Adam Smith |
| John Smith |
| Carol Smith |
+-------------+
4 rows in set (0.00 sec)
以下是实现SELECT LIKE和CHAR_LENGTH的查询-
mysql> select * from DemoTable-> where Name LIKE '%Smith%'
-> and char_length(Name) < 11;
这将产生以下输出-
+------------+| Name |
+------------+
| Adam Smith |
| John Smith |
+------------+
2 rows in set (0.00 sec)
以上是 在单个MySQL查询中实现SELECT LIKE和CHAR_LENGTH() 的全部内容, 来源链接: utcz.com/z/316807.html