我的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
答案 0 :(得分:3)
只需更新表格并使用REPLACE()
功能
UPDATE table
SET Url = REPLACE(Name,' ', '-')