Resources | Subject Notes | Information Communication Technology ICT
In database systems, searching for specific data can be achieved using various criteria. One powerful tool for flexible searching is the use of wildcards. Wildcards allow you to represent unknown or variable characters in a search query, making it possible to retrieve a wider range of results.
Two common wildcard characters are used in database searches:
The '?' wildcard is used to find records where a specific character is unknown. For example:
The '*' wildcard is used to find records where a sequence of characters is unknown or can be of varying lengths. For example:
Some database systems allow you to combine wildcards to create more complex search queries. The exact syntax for combining wildcards can vary depending on the database system being used.
Search Query | Description |
---|---|
'S*t' | Finds records starting with 'S' followed by any number of characters and ending with 't'. Examples: 'Sat', 'Start', 'Smart'. |
'Jo?n' | Finds records where the first letter is 'J', the second letter is any character, and the third letter is 'n'. Examples: 'Jon', 'Join', 'Jonah'. |
'A*' | Finds records starting with 'A' followed by any number of characters. Examples: 'Apple', 'Alice', 'A'. |
When using wildcards, it's important to be mindful of the following: