mysql部門調換sql語句分享。本站提示廣大學習愛好者:(mysql部門調換sql語句分享)文章只能為提供參考,不一定能成為您想要的結果。以下是mysql部門調換sql語句分享正文
將cdb_pms表subject字段中的Welcom to調換成 迎接惠臨
UPDATE `cdb_pms`
SET `subject` = REPLACE(`subject`, 'Welcome to', '迎接惠臨')
WHERE INSTR(`subject`,'Welcome to') > 0
調換cdb_posts表的message字段,將“viewthread.php?tid=3989”調換成“viewthread.php?tid=16546”
UPDATE `cdb_posts`
SET `message`= REPLACE(`message`, 'viewthread.php?tid=3989', 'viewthread.php?tid=16546')
WHERE INSTR(`message`,'viewthread.php?tid=3989') > 0 ;
刪除一切的空格
UPDATE `es_product` SET `pro_pub_time` = TRIM(`pro_pub_time`)
刪除一切飽含'['或許']'或許'.'的字符
UPDATE `es_product` SET `pro_pub_time` = REPLACE(`pro_pub_time`, '[','') WHERE INSTR(`pro_pub_time`,'[') > 0
UPDATE `es_product` SET `pro_pub_time` = REPLACE(`pro_pub_time`, ']','') WHERE INSTR(`pro_pub_time`,']') > 0
UPDATE `es_product` SET `pro_pub_time` = REPLACE(`pro_pub_time`, '.','-') WHERE INSTR(`pro_pub_time`,'.') > 0
調換一切含中文'-'的為英文'-'
UPDATE `es_product` SET `pro_pub_time` = REPLACE(`pro_pub_time`, '-','-') WHERE INSTR(`pro_pub_time`,'-') > 0
將一切的年代都調換成'-'
UPDATE `es_product` SET `pro_pub_time` = REPLACE(`pro_pub_time`, '年','-') WHERE INSTR(`pro_pub_time`,'年') > 0
UPDATE `es_product` SET `pro_pub_time` = REPLACE(`pro_pub_time`, '月','-') WHERE INSTR(`pro_pub_time`,'月') > 0
將一切'2005-04-'這類類型的調換成'2005-04-01'
UPDATE `es_product` SET `pro_pub_time` = CONCAT( `pro_pub_time`, '01') WHERE SUBSTRING_INDEX( `pro_pub_time`, '-', -1) = '' AND LENGTH(`pro_pub_time`) > 0 AND LENGTH(`pro_pub_time`) > 5
將一切'2005-'這類類型調換成'2005-01-01'
UPDATE `es_product` SET `pro_pub_time` = CONCAT( `pro_pub_time`, '01-01') WHERE INSTR(`pro_pub_time`,'-') > 0 AND LENGTH(`pro_pub_time`) = 5
將一切 飽含'-',然則位數小於8的改成追加'-01'
UPDATE `es_product` SET `pro_pub_time` = CONCAT( `pro_pub_time`, '-01') WHERE INSTR(`pro_pub_time`,'-') > 0 AND LENGTH(`pro_pub_time`) < 8
將一切'2005'如許的改成'2005-01-01'
UPDATE `es_product` SET `pro_pub_time` = CONCAT(`pro_pub_time`,'-01-01') WHERE INSTR(`pro_pub_time`,'-') = 0 AND LENGTH(`pro_pub_time`) = 4
最初將一切'2005-01-01'格局化成'2005年01月'
UPDATE `es_product` SET `pro_pub_time` = DATE_FORMAT(`pro_pub_time`,'%Y年%m月') WHERE INSTR(`pro_pub_time`,'-') > 0