开发者

Limit characters for mysql_query(select) lookup

开发者 https://www.devze.com 2023-01-13 01:54 出处:网络
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 t开发者_开发问答here

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 t开发者_开发问答here a way to mysql_query("select text_column from random_table limit_char_count 500")?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消