반응형
MySQL의 기존 필드에 문자열을 추가하려면 어떻게 해야 합니까?
모든 레코드의 코드를 현재 상태로 업데이트하고 싶은데, 표준적인 아이디어가 있습니까?
예를 들어 코드가 apple_1 및 apple_2인 경우 apple_1_standard 및 apple_2_standard여야 합니다.
이전:
id code
------------
1 apple_1
1 apple_2
Psuedo 쿼리:
update categories set code = code + "_standard" where id = 1;
예상 결과:
id code
----------------------
1 apple_1_standard
1 apple_2_standard
문자열 연결을 위해 MySQL의 함수를 사용해야 합니다.
UPDATE categories SET code = CONCAT(code, '_standard') WHERE id = 1;
이미지 필드를 업데이트하여 늘 필드를 무시하고 완전한 URL을 추가합니다.
UPDATE test SET image = CONCAT('https://my-site.com/images/',image) WHERE image IS NOT NULL;
언급URL : https://stackoverflow.com/questions/3765631/how-can-i-append-a-string-to-an-existing-field-in-mysql
반응형
'programing' 카테고리의 다른 글
ubuntu 서버에서 pip install mariadb 오류 발생 (0) | 2022.09.19 |
---|---|
Mockito : doAnswer vs then Return (0) | 2022.09.19 |
데이터 테이블에서 기본 슬롯 isOpen 수정 Vuetify 2.0 (0) | 2022.09.19 |
파일 크기(바이트)를 사람이 읽을 수 있는 문자열로 변환 (0) | 2022.09.14 |
python's eval() vs. ast.literal_eval() 사용 (0) | 2022.09.14 |