replace()함수를 사용하여 데이터를 치환할 수 있다.
# 테이블 데이터 조회
select * from table_name
where idx = 1 and status_code!= 3
# 변경할 값 확인
SELECT REPLACE(name, 'ABC0', 'ABC00') AS 'replaced_data' FROM table_name
where idx = 1 and status_code!= 3 and name like "%ABC0%"
# update로 값 변경
UPDATE table_name SET name = REPLACE(name, 'ABC0', 'ABC00')
where idx = 1 and status_code!= 3 and name like "%ABC0%"
검색결과에서 abc0과 abc00의 결과가 달라서 데이터를 수정했다. (검색엔진 문제 같은데 정확한 원인은 아직 모름)
REPLACE()를 이용하면 된다.
'Development > MySql' 카테고리의 다른 글
[MySQL] 테이블 깨졌을 때 복구하기 (0) | 2023.08.04 |
---|---|
[MySQL] checking permissions (0) | 2023.05.04 |
[MySQL] 테이블 전체 구조와 데이터 복사하기 (0) | 2023.03.15 |
[MySQL] user 생성 및 권한 부여 (0) | 2023.02.23 |
[MySql] DATETIME 값 수정하기(update) (0) | 2023.02.13 |