MySQL Left() or SUBSTRING()?

2019-02-12 05:10发布

Both of these queries will produce same result. But which one is better, faster.

SELECT LEFT(textField, 100) AS first100Chars

SELECT SUBSTRING(textField, 1, 100 )

Thanks.

2条回答
够拽才男人
2楼-- · 2019-02-12 05:24

By itself there is little difference, however left can potentially utilize an index while substring cannot.

查看更多
Anthone
3楼-- · 2019-02-12 05:27

Substring will take little more time than left function. Though your case is straight forward use left function only.

查看更多
登录 后发表回答