开发者

How can I update many rows with SQL in a single table?

I have a table and one of the columns holds web addresses like: 'http://...' or 'https://...'.

The problem is that there are some invalid entries, like 'shttp://...' or '#http//...' (the first character is invalid) and I want to correct all of them.

I use the following SQL statement:

'SELECT [...] FROM MyTable WHERE WebAddress LIKE '_http%'

and I successf开发者_如何学运维uly get the problematic rows.

But how am I going to change/correct all of them using an UPDATE statement? If you have some other solution please share it!


Simply change the SELECT to an UPDATE (of course, with some syntax changes) with a "fix" expression

UPDATE
   MyTable
SET
    WebAddress = SUBSTRING(WebAddress, 2, 8000)
WHERE
    WebAddress LIKE '_http%'


You Can use Sub string property as you can trim odd letters .Also like '_word start' suitable for your question

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜