[英]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
有沒有辦法通過SQL
或PHP
做到這一點
只需更新表並使用REPLACE()
函數
UPDATE table
SET Url = REPLACE(Name,' ', '-')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.