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

怎么把一个字段拆分为三个字段,然后对表中的另外三个字段赋值,进行修改?
我有一个表MobileInfo,其中有一个appversion的字段,根据这个字段截分为三部分,然后把三部分赋值给MobileInfo表的另外三个字段(company,brand,maincom);
比如appversion的值是1.0_1.6_9,maincom=1.0 company=1,brand=6_9要截成这样,然后修改MobileInfo表?请问这个要怎么写sql语句,我用的是mysql数据库! 在线等,很急!!!!


------解决方案--------------------
SQL code
UPDATE MobileInfo 
SET company = SUBSTR(appversion,1,INSTR(appversion,'_')-1), 
brand = SUBSTR(SUBSTR(appversion,INSTR(appversion,'_')+1),1,INSTR(SUBSTR(appversion,INSTR(appversion,'_')+1),'_')-1), 
maincom = SUBSTR(SUBSTR(appversion,INSTR(appversion,'_')+1),INSTR(SUBSTR(appversion,INSTR(appversion,'_')+1),'_')+1) ;