在mysql中选择表列数据的一部分 [英] select part of table column data in mysql

查看:269
本文介绍了在mysql中选择表列数据的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张桌子'photo',其中包含2000个条目.该表有一个名为photo_note的列,其中包含以下格式的数据,但具有不同的放大率值.

I have a table 'photo' which contains 2000 entries. That table has a column called photo_note which contains data in the format below but with different magnification value.

Magnification 30x. The resolution varies depending on.....

我需要从分辨率"开始选择其余的列数据,并将其附加到另一个字段"photo_note_2"

I need to select the rest of the column data starting with 'The resolution' and append it in another field 'photo_note_2'

任何建议如何在mysql中做到这一点最受赞赏

Any suggestion how to do this in mysql is most appreciated

推荐答案

SUBSTRING可让您返回字符串的一部分. INSTR返回一个字符串在其他字符串中的位置.

SUBSTRING lets you return part of a string. INSTR returns the position of a string in other string.

如果您知道所有列均具有分辨率",则:

If you know that all the columns will have 'The resolution', then:

SELECT SUBSTRING(photo_note, INSTR(photo_note, 'The resolution')) from table;

如果您知道所有人都会有一个'x. '在您要检索的字符串之前,然后

If you know that all will have a 'x. ' before the string you want to retrieve, then

SELECT SUBSTRING(photo_note, INSTR(photo_note, 'x. ') + 3) from table;

您可以在此处.

这篇关于在mysql中选择表列数据的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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