2012-04-19 4 views
1

어떻게 내가 MySQL 5.5에서합니까? concat을 생각하고 있었지만 더 간단한 것이 있다고 생각합니다.SQL 업데이트 문에 문자열에 행 ID를 삽입

id content 
1 
2 

update posts set content='here is content ' + this.id 

그래서 :

id content 
1 here is content 1 
2 here is content 2 

들으

답변

1

:

update posts 
    set content=CONCAT('here is content ', CAST(id as CHARACTER)) 

여기에 SQLFiddle에 대한 테스트에 link이 있습니다.

+1

http://sqlfiddle.com에서 시도해 볼 수 있습니다. –

+1

@MichaelBuen 감사합니다! 나는 그것이 작동한다는 것을 지금 알고있다. (http://sqlfiddle.com/#!2/e2c13/4)! 훌륭한 도구! – dasblinkenlight

0

같아요 : 이것은 당신이 필요하지

update comment set comment=concat('here is a comment: ', id,' these are other things'); 
관련 문제