2016-08-06 5 views
-1

다음 네 개의 명령문을 하나로 결합 할 수 있습니까?mysql 업데이트 및 바꾸기

UPDATE `comment_common` 
SET comment = replace(comment, '??', '?'); 

UPDATE `comment_common` 
SET comment = replace(comment, ' ?', '?'); 

UPDATE `comment_common` 
SET comment = replace(comment, '!!', '!'); 

UPDATE `comment_common` 
SET comment = replace(comment, ' !', '!'); 

답변

0

아래처럼 뭔가를 시도 할 수 있습니다 :

SET @str := '??'; 

SELECT 
REPLACE(
    REPLACE(
     REPLACE(
      REPLACE(@str,'??','?'),' ?','?'), 
      '!!','!' 
    ), 
' !', 
'!' 
) 

를 귀하의 경우 :

UPDATE `comment_common` 
SET comment = REPLACE (
    REPLACE (
     REPLACE (
      REPLACE (
       comment, 
       '??', 
       '?' 
      ), 
      ' ?', 
      '?' 
     ), 
     '!!', 
     '!' 
    ), 
    ' !', 
    '!' 
)