开发者

MySQL - SQL length question

开发者 https://www.devze.com 2023-02-16 08:12 出处:网络
What is the correct SQL statement for SELECT kw where l开发者_开发知识库ength(kw) > 3 FROM data group by kwYou need to re-order the query and use the CHAR_LENGTH() function:

What is the correct SQL statement for

SELECT kw where l开发者_开发知识库ength(kw) > 3 FROM data group by kw


You need to re-order the query and use the CHAR_LENGTH() function:

SELECT kw FROM data WHERE CHAR_LENGTH(kw) > 3 GROUP BY kw;

It should be noted that using functions in the WHERE clause is frowned upon as the function is executed for every row of the data table.

If you are not restricted by disk space, consider re-architecting your solution so you can store the required information in another column (in this case, store the length of kw in a kw_length). This will speed the query up and save unnecessary processor cycles.

0

精彩评论

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

关注公众号