开发者

select from and update into the same table

I have table (TEST) with columns (tid, title, subject). I need to select first 30 chars of (subject) and update it in to its (title) column as follows. When I tried the following, it says SQL command not properly开发者_开发技巧 ended. Any idea?

update a set a.title = substr(b.subject, 0, 30) from trkowner.test a join trkowner.test b on a.tid = b.tid;


You don't need join in this case. Just perform:

update trkowner.test set title = substr(subject, 0, 30)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜