How to substring a MySQL table column

后端 未结 6 2082
借酒劲吻你
借酒劲吻你 2020-12-25 09:32

I want to select a field from table and substring it.

For example:

VAN1031 --> 1031

I tried this, but is improper syntax:

<
6条回答
  •  执笔经年
    2020-12-25 10:19

    I noticed that mysql index starts from 1 instead of zero as many programming languages did.

    SELECT SUBSTRING(R.regNumber,1,3) FROM registration AS R
    

    Returns VAN and

    SELECT SUBSTRING(R.regNumber,4) FROM registration AS R
    

    Returns the remaining part of the string as 1031

提交回复
热议问题