SQL表中某字段数据的读取

来源:百度知道 编辑:UC知道 时间:2024/07/08 12:13:51
A表中有字段名AAA
该字段的记录数据格式为XX,YY,ZZ
请问我要读取这个记录数据中的XX程序该怎么写?
读取YY又该怎么写?读取ZZ呢?

字段AAA | 字段BBB | 字段CCC
---------------------------------------
XX,YY,ZZ |...............|............
XX,YY,ZZ |...............|............

问题解决后再给50分
程序最好写的简单明了一些!~~ 感谢各位啦!~

select substring(fileName,1,1) from dbo.FileInfo where fileId = 4
(fileId = 4 是什么意思?)

select aaa from tables where aaa REGEXP "XXX,[a-zA-Z],[a-zA-Z]\|\w"#读XXX

XX,YY,ZZ等数据都是变化的 不是固定值

select fileName from FileInfo where fileId = 4 --查询出来的结果是'我的文档'

-现在我要取‘我’
select substring(fileName,1,1) from dbo.FileInfo where fileId = 4
-取'的'
select substring(fileName,2,1) from dbo.FileInfo where fileId = 4
-取'文'
select substring(fileName,3,1) from dbo.FileInfo where fileId = 4
-取'档'
select substring(fileName,4,1) from dbo.FileInfo where fileId = 4

substring(列名,开始位置,取几位)

select aaa from tables where aaa REGEXP "XXX,[a-zA-Z],[a-zA-Z]\|\w"#读XXX
select aaa from tables where aaa REGEXP "[a-zA-Z],YYY,[a-zA-Z]\|\w"#读YYY
..............