簡體   English   中英

SQL:使用替換空間從列復制到另一列

[英]SQL: Copy from column to another column with replace space

我在DataBase有這樣的表:

ID       Name              Url         Date
11   News title test2               22-10-2014
12   News title test3               22-10-2014
13   News title test4               22-10-2014

現在,我需要將值從Name復制到Url並將空格替換為-

因此,該表必須像復制后一樣:-

ID       Name                     Url                    Date
11   News title test2       News-title-test2           22-10-2014
12   News title test3       News-title-test2           22-10-2014
13   News title test4       News-title-test2           22-10-2014

有沒有辦法通過SQLPHP做到這一點

只需更新表並使用REPLACE()函數

UPDATE table
SET Url = REPLACE(Name,' ', '-')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM