網域名稱俱樂部

網域名稱俱樂部 (https://www.domainclub.org/index.php)
-   問題意見與求助 (https://www.domainclub.org/forumdisplay.php?f=18)
-   -   mysql 問題 replace concat (https://www.domainclub.org/showthread.php?t=39572)

Matt 2016-05-19 03:49 PM

mysql 問題 replace concat
 
mysql 問題 ,
一個table 有兩個 columns ,
其中
columnA值為 x1234,
columnB值為 35765-xyab.pin ,
我要替換35765-xyab.pin 為35765-xyab+`column A`+.pin,
即35765-xyabX1234.pin ,

columnB值為 35765-xyab.pin , 其中-xyab.pin為固定值,35765是變化的,
columnA 的值也是變化的

mysql 該如何寫 ?

USA 2016-05-19 04:44 PM

update + subquery

Matt 2016-05-19 06:10 PM

引用:

update + subquery
我研究一下 好像很難

columnB值為 35765-xyab.pin , 其中-xyab.pin為固定值,35765是變化的,
columnA 的值也是變化的


有沒有辦法 像下面 再加個什麼?

UPDATE `table` SET `columnB` = REPLACE( `columnB` , "-xyab.pin", "'-xyab'.`column A`.'.pin'" ) WHERE `id` =56789

yumi 2016-05-20 09:45 AM

update tablename set columnB=concat(left(columnB,10),columnA,'.pin')

这样行吗
前提是35765-xyab是固定的10位
而且所有的行都要替换

Matt 2016-05-21 11:03 AM

引用:

作者: yumi (文章 201945)
update tablename set columnB=concat(left(columnB,10),columnA,'.pin')

这样行吗
前提是35765-xyab是固定的10位
而且所有的行都要替换

謝謝 我研究看看 感恩~yes


所有時間均為 +8。現在的時間是 04:26 PM

Powered by vBulletin® 版本 3.8.4
版權所有 ©2000 - 2024,Jelsoft Enterprises Ltd.