gpt4 book ai didi

mysql - 在 MySQL 中删除 400 个字符或 10 个句子后的字符串

转载 作者:行者123 更新时间:2023-11-30 23:24:11 25 4
gpt4 key购买 nike

我有一个表,其中一个字段(描述)可以变化,理想情况下,我想删除 400 个字符后或 10 个句子后的任何内容(但在句子末尾,要么没有任何内容,要么添加 ....让它看起来更自然)。

我得到了位置

SELECT description,LOCATE('.',description)   as pos
FROM table
WHERE locate('.',description)>20;

但是我不能再进一步了;这是最好的方法吗?

最佳答案

要截断为 10 个句子,请使用 substring_index :

substring_index( description, '.', 10 )

您的查询:

SELECT  concat(
left( substring_index( description, '.', 10 )
,397
)
,'...' )
FROM table
WHERE len( description ) > 400

注意:未测试。

关于mysql - 在 MySQL 中删除 400 个字符或 10 个句子后的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14106463/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com