这是我想要做的,获取以“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/