MySQL Left()或SUBSTRING()? [英] MySQL Left() or SUBSTRING()?

查看:84
本文介绍了MySQL Left()或SUBSTRING()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两个查询都将产生相同的结果.但是哪个更好,更快.

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 )

谢谢.

推荐答案

彼此之间几乎没有区别,但是left可以利用索引,而substring则不能.

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

这篇关于MySQL Left()或SUBSTRING()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆