HOW TO USE WILDCARD CHARACTERS IN SQL?

279 viewsSQLSQL
0
Saraswat World Changed status to publish June 8, 2023
0
WILDCARD in SQL
WILDCARD in SQL

WILDCARDย ย characters are used to substitute one or more characters in a string and used with LIKE operatorย  which is used in a WHERE clause to search for a specified pattern in a column.

Syntax in SQL to use Wildcard characters โ€“

SELECT(ColumnName(s))ย FROMย <TableName>ย WHERE<ColumnName>LIKEย <pattern> ;

Examples of wildcard characters use in SQL-

Replace the word pattern provided in below example with the pattern provided in following table, its result is explained in table.

SELECT * FROMย Customersย WHEREย CustomerNameย LIKEย โ€˜patternโ€™;

Wildcard characters in SQL Server-

Symbol Represents Pattern Query result returns customer name having character
% Zero or more characters ab% a at 1stย and b at 2ndย position
_ A single character a_d a at 1stย  and d at 3rdย  position
[] Any single character within [] a[mo]d a at 1Stย  & d at 3rdย  & either m or o at 2nd position
^ Any single character not in [] a[^mo]d a at 1Stย  & d at 3rdย  & neither m nor o at 2nd position
โ€“ Any single character within given range a[m-p]d a at 1Stย , d at 3rdย  & any 1 from range m-p at 2ndย position
Wildcard characters usage in SQL
Saraswat World Changed status to publish June 8, 2023
Write your answer.

Posted

in

Tags:

Comments

Leave a Reply

A Tribute to Dilip Kumar