日期:2014-05-16  浏览次数:20608 次

删除字段的一个字符

CREATE TABLE bb1
(
? name character varying,
? value character varying,
? id bigint
)

?

truncate bb1;
?
INSERT INTO bb1(name, value, id)VALUES ('ab', '11', 1);
INSERT INTO bb1(name, value, id)VALUES ('bc', '11', 2);
INSERT INTO bb1(name, value, id)VALUES ('fb', '13', 3);
INSERT INTO bb1(name, value, id)VALUES ('c', '21', 4);
INSERT INTO bb1(name, value, id)VALUES ('c', '21', 5);

select * from bb1 a order by id

删除右边的第一个字符
update bb1 set name=Right(name,(char_length(name)-1)) where name like 'b%'

删除左边的第一个字符
update bb1 set name=left(name,(char_length(name)-1)) where name like '%b'