mysql - 在 MySql 中使用 REGEXP 嵌套 SELECT

标签 mysql sql select

这是我想要做的,获取以“the”开头的书名,然后是 3 到 8 个字符,然后是带有特定文本的“CONCAT”主题。 我试过了,但没有成功:

select concat((select title from books where title REGEXP '^the.{3,8}$'), '.....') from books;

这是我得到的:

+-----------------------------------------------------------------------------+
| concat((select title from books where title REGEXP '^the.{3,8}$'), '.....') |
+-----------------------------------------------------------------------------+
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
| The Circle.....                                                             |
+-----------------------------------------------------------------------------+
16 rows in set (0.00 sec)

最佳答案

因为我不知道你想要什么作为输出,如果 Mysql 版本 >= 5.5,类似的东西会起作用:

SELECT concat(title, '....') as My_title
FROM book
WHERE title REGEXP '^the.{3,8}$'

关于mysql - 在 MySql 中使用 REGEXP 嵌套 SELECT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47513334/

相关文章:

php - Laravel 聊天中的长轮询 : Why is the div not updating itself?

MySQL:从 2 个相互关联的表中获取最新消息

php - 如何在 PHP 中将 printf 添加到成功的查询返回中

javascript - 在meteor javascript中选择了错误的选项值

mysql - 从 MySQL 表中更新 x 行

mysql - 使用高偏移量时查询速度相当慢

mysql - 当表 A 的 email 等于表 B 的 email 时,更新表 A 中的某一列

SQL模拟自增字段

mysql - 如何计算历史表中每个状态的数量请参阅输出

Mysql不选择空值