14. Wildcards
1. Wildcard Characters
- 와일드카드 문자는 문자열에서 하나 이상의 문자를 대체하는 데 사용된다.
- 와일드카드 문자는
LIKE
연산자와 사용된다. LIKE
연산자는 특정 패턴을 검색하기 위해WHERE
절에서 사용된다.
2. Wildcard Characters in MS Access
Symbol | Description | Example |
---|---|---|
* |
Represents zero or more characters | bl* finds bl, black, blue, and blob |
? |
Represents a single character | h?t finds hot, hat, and hit |
[] |
Represents any single character within the brackets | h[oa]t finds hot and hat, but not hit |
! |
Represents any character not in the brackets | h[!oa]t finds hit, but not hot and hat |
- |
Represents any single character within the specified range | c[a-b]t finds cat and cbt |
# |
Represents any single numeric character | 2#5 finds 205, 215, 225, 235, 245, 255, 265, 275, 285, and 295 |
3. Wildcard Characters in SQL Server
Symbol | Description | Example |
---|---|---|
% |
Represents zero or more characters | bl% finds bl, black, blue, and blob |
_ |
Represents a single character | h_t finds hot, hat, and hit |
[] |
Represents any single character within the brackets | h[oa]t finds hot and hat, but not hit |
^ |
Represents any character not in the brackets | h[^oa]t finds hit, but not hot and hat |
- |
Represents any single character within the specified range | c[a-b]t finds cat and cbt |
Demo Database
- 다음은 Northwind 샘플 데이터베이스의
Customers
테이블이다.
4. Using the %
Wildcard
- 다음은
City
가"ber
"로 시작하는 모든 고객을 선택한다.
- 다음은
City
에"es"
가 있는 모든 고객을 선택한다.
5. Using the _
Wildcard
- 다음은
City
가 임의의 문자로 시작하고"ondon"
으로 끝나는 모든 고객을 선택한다.
- 다음은
City
가"L"
로 시작하고 임의의 문자,"n"
, 임의의 문자,"on"
으로 끝나는 모든 고객을 선택한다.
6. Using the [charlist]
Wildcard
- 다음은
City
가"b"
,"s"
또는"p"
로 시작하는 모든 고객을 선택한다.
- 다음은
City
가"a"
,"b"
또는"c"
로 시작하는 모든 고객을 선택한다.
7. Using the [!charlist]
Wildcard
- 다음은
City
가"b"
,"s"
또는"p"
로 시작하지 않는 모든 고객을 선택한다.
- 또는