How to substring a MySQL table column

后端 未结 6 2094
借酒劲吻你
借酒劲吻你 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:16

    SELECT substring(R.regnumber FROM 4) FROM registration AS R;
    

    and if you want to take the part as an integer not a string you can write:

    SELECT CAST(substring(R.regnumber FROM 4) AS UNSIGNED) FROM registration as R;
    

提交回复
热议问题