我的表是行
ID Twitter Facebook UserID
1 @kamel http:www.fb.com/rtymal 10
2 http:www.twitter.com/rlyill makmal 170
3 ymikll mtymal 15
4 @wiled makfrl 13
我需要为没有它的所有行添加http:www.twitter.com
。与facebook相同。
所以在表格中我需要像
这样的结果ID Twitter Facebook UserID
1 http:www.twitter.com/kamel http:www.fb.com/rtymal 10
2 http:www.twitter.com/rlyill http:www.fb.com/makmal 170
3 http:www.twitter.com/ymikll http:www.fb.com/mtymal 15
4 http:www.twitter.com/wiled http:www.fb.com/makfrl 13
答案 0 :(得分:1)
如果要更新表格内容:
UPDATE tablename SET Twitter = concat('http:www.twitter.com/', Twitter)
WHERE Twitter not like 'http:www.twitter.com%'
如果您只想修改结果集,请在选择中执行类似操作:
select case when Twitter not like 'http:www.twitter.com%' then
concat('http:www.twitter.com/', Twitter) else Twitter end
from tablename