SQL Server 데이터베이스에서 데이터 정제하기
Miriam Antona
Software Engineer
SELECT * FROM series
| id | name | contact_number | ... |
|-----|-----------------|----------------|-----|
| 1 | Adventure Time | 555-906-8845 | ... |
| 2 | Dexter | 555-156-8845 | ... |
| 3 | Futurama | 555-210-9951 | ... |
| 4 | Game of Thrones | 555-543-6641 | ... |
| ... | ... | ... | ... |
LIKE로 패턴 매칭을 수행할 수 있습니다.| 와일드카드 문자 | 설명 | 예시 |
|---|---|---|
| % | 길이 0 이상 임의의 문자열 | WHERE contact_number LIKE '555-%' |
| _ (밑줄) | 임의의 한 글자 | WHERE contact_number LIKE '___-___-____' |
| [] | 지정한 범위/집합 내 임의의 한 글자 | WHERE contact_number LIKE '[2-9][0-9][0-9]-[2-9][0-9][0-9]-[0-9][0-9][0-9][0-9] |
| [^] | 지정한 범위/집합에 속하지 않는 임의의 한 글자 | WHERE contact_number LIKE '[^2-9]' |
SELECT name, contact_number
FROM series
WHERE contact_number LIKE '555%'
| name | contact_number |
|-----------------|----------------|
| Adventure Time | 555-906-8845 |
| Dexter | 555-156-8845 |
| Futurama | 555-210-9951 |
| Game of Thrones | 555-abc-6641 |
| ... | ... |
SELECT
name,
contact_number
FROM series
WHERE contact_number NOT LIKE '555%'
| name | contact_number |
|-----------------|----------------|
| The Good Doctor | 000-930-1274 |
SELECT
name,
contact_number
FROM series
WHERE contact_number LIKE '[2-9][0-9][0-9]-[2-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'
| name | contact_number |
|----------------|----------------|
| Adventure Time | 555-906-8845 |
| Futurama | 555-210-9951 |
| Homeland | 555-985-6314 |
| Westworld | 555-456-1234 |
| ... | ... |
SELECT
name,
contact_number
FROM series
WHERE contact_number NOT LIKE '[2-9][0-9][0-9]-[2-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'
| name | contact_number |
|-----------------|----------------|
| Dexter | 555-156-8845 |
| Game of Thrones | 555-abc-6641 |
| The Good Doctor | 000-930-1274 |
SQL Server 데이터베이스에서 데이터 정제하기