如何子字符串MySQL表列 [英] How to substring a MySQL table column
本文介绍了如何子字符串MySQL表列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从表格中选择一个字段并将其子字符串。
I want to select a field from table and substring it.
例如:
VAN1031 --> 1031
我试过这个,但语法不正确:
I tried this, but is improper syntax:
SELECT SUBSTR(R.regnumber,3,3) from registration R
如何做到这一点?
推荐答案
你不需要第三个参数要选择特定索引右侧的所有字符:
You don't need the third argument (length) if you want to select all the characters to the right of a specific index:
SELECT SUBSTR(R.regnumber, 4)
FROM registration AS R
我还将开始索引更改为4,因为在SQL字符串中是1索引而不是0-索引,因为它们在许多流行的编程语言。
I also changed the start index to 4 because in SQL strings are 1-indexed and not 0-indexed as they are in many popular programming languages.
这篇关于如何子字符串MySQL表列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文