开发者

select from and update into the same table

开发者 https://www.devze.com 2023-04-04 19:00 出处:网络
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

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

精彩评论

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