MySQL +子串怎么办? +替换? [英] How to do MySQL + Substring? + replace?

查看:74
本文介绍了MySQL +子串怎么办? +替换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我对SQL不太满意,并且希望能够变得更好.

  • I am not very good with SQL and would like to be able to become better.

我在尝试执行某种表操作时遇到了一些麻烦.

I am having some trouble trying to preform a certain table manipulation.

我希望能够从下面的ProgUID列中选择子字符串

I would like to be able to select the substring out of the ProgUID column below

类似...

SUBSTRING(table.ProgUID,3,12);

这将为我提供ProgUID P-CAMVE-9701-1的CAMVE-9701(从开头删除P-,从结尾删除-1),然后将子字符串插入该行UID.

which would give me CAMVE-9701 for the ProgUID P-CAMVE-9701-1 (removing the P- from the beginning and the -1 from the end), and then insert the substring into that rows UID.

我认为这应该很容易,并且我一直在试图找出答案,但是运气还不够.

I assume this should be fairly easy, and I have been trying to figure it out but havent had much luck.

如果有更好的方法,请告诉我!

If there is a better approach please let me know!

提前感谢您的想法/帮助!

Thanks in advance for your thoughts / help!

推荐答案

使用UPDATE语句

UPDATE tableName
   SET UID = SUBSTRING(ProgUID,3,12)

  • 请参见SQLFiddle演示
  • 这篇关于MySQL +子串怎么办? +替换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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