日期:2014-05-16 浏览次数:20914 次
--创建a表 CREATE TABLE `a` ( `aid` int(11) DEFAULT NULL, `ades` varchar(50) DEFAULT NULL ); --创建b表 CREATE TABLE `b` ( `bid` int(11) DEFAULT NULL, `bdes` decimal(20,8) DEFAULT NULL ); --插入数据 INSERT INTO a VALUES(1,'0.5元/手'); INSERT INTO a VALUES(2,'52.666元/手'); INSERT INTO a VALUES(1,'100.2元/手'); INSERT INTO a VALUES(1,'5元/手'); INSERT INTO a VALUES(1,'3元/手'); INSERT INTO a VALUES(1,'88.9元/手'); mysql> select * from a; +------+-------------+ | aid | ades | +------+-------------+ | 1 | 0.5元/手 | | 2 | 52.666元/手 | | 1 | 100.2元/手 | | 1 | 5元/手 | | 1 | 3元/手 | | 1 | 88.9元/手 | +------+-------------+
insert into b select aid,SUBSTRING_INDEX(ades,'元',1) from a;
------解决方案--------------------
select aid,ades+0 from a;
------解决方案--------------------
楼上正解~