数据表其中一个字段的值如“11.22.33”类型,我想把“11”取出来,如何截取字符串并获得该值?谢谢

[复制链接]
查看11 | 回复4 | 2013-4-24 10:18:55 | 显示全部楼层 |阅读模式
Oracle:-- 没有直接的函数.CREATE table test (a varchar(100));insert into test values('test.abc.oracle.com.cn');-- 获取第一个.SELECTSUBSTR(a, 1, INSTR (a, '.') -1 ) AS ResultFROMtest;RESULT---------testSQLServer-- 没有直接的函数.CREATE table test (a varchar(100));insert into test values('test.a...
回复

使用道具 举报

千问 | 2013-4-24 10:18:55 | 显示全部楼层
假设字符为变量@aselect left(@a,charindex('.',@a)-1)...
回复

使用道具 举报

千问 | 2013-4-24 10:18:55 | 显示全部楼层
这个语句你这样写select left((select c1 from t1),charindex('.',select c1 from t1)-1) from table...
回复

使用道具 举报

千问 | 2013-4-24 10:18:55 | 显示全部楼层
left(字段,2)...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行