开发者

Update table SQL query help

I have a database student(attribute - studentid). studentid is a varchar. 开发者_运维百科Now I want to add 'P' at the end of all studentids.

12 -> 12P 234 -> 234P

What will be the sql query for this?


UPDATE mytable
SET student_id = student_id + 'P'   --assumes already varchar 
WHERE RIGHT(student_id, 1) <> 'P'   --to stop having PP at end...


UPDATE mytable SET student_id=CONCAT(student_id,'P');//mysql


This is for SQL Server:

select cast(Studentid as varchar) +'P' from student


update @t
set studentid = studentid + 'P'
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜