mysql_query(select) 查找的限制字符

发布于 2024-09-15 14:38:35 字数 178 浏览 3 评论 0原文

有没有一种有效的方法来限制 mysql 查询查找的字符数?那么,如果一个文本列字段有18000个字符,但我只需要查询500个字符,有没有办法 mysql_query("select text_column from random_table limit_char_count 500") ?

Is there an efficient way to limit the number of characters for a mysql query lookup? So, if a text column field had 18000 characters, but I only need to query 500 characters, is there a way to mysql_query("select text_column from random_table limit_char_count 500")?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挖个坑埋了你 2024-09-22 14:38:35

使用 SUBSTRING() 函数怎么样?
下面的示例选择从第一个位置开始的 4 个字符

SELECT SUBSTRING(text_column,1,4) 
FROM random_table
WHERE something = something else

EDIT - 编辑基于 - 对于所有形式的 SUBSTRING(),要从中提取子字符串的字符串中第一个字符的位置被视为 1。

How about using the SUBSTRING() function?
Below example selects 4 characters starting from 1st position

SELECT SUBSTRING(text_column,1,4) 
FROM random_table
WHERE something = something else

EDIT - edited based on - for all forms of SUBSTRING(), the position of the first character in the string from which the substring is to be extracted is reckoned as 1.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文