Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (55.6k points)

Can anyone explain wildcard in SQL?

1 Answer

0 votes
by (119k points)

In SQL, wildcard character is used with the LIKE operator to substitute one or more characters of a string. LIKE operator is used in WHERE clause to find for a particular pattern in a column.

The following are the wild characters in SQL server

  • ‘ % ‘ ­‑  means zero or more characters
  • ‘ _ ‘  -  means a single character
  • ‘ [ ] ‘ -  means any single character within brackets
  • ‘ ^ ’  -  means any character not in the brackets

Here are the few examples how you can use WILDCARD characters:

  • WHERE EmployeerName LIKE 'a%'         -  returns any values that start with "a"
  • WHERE EmployeeName LIKE '_r%'         -  returns any values that have "r" in the second position
  • WHERE EmployeeName LIKE 'a_%_%'   -  returns any values that start with "a" and are at least 3 characters in length

You can check out this SQL tutorial by Intellipaat if you want to learn more about wildcard characters along with examples.

Related questions

0 votes
1 answer
0 votes
1 answer
asked May 4, 2023 in SQL by neelimakv (32.5k points)
0 votes
1 answer
asked Apr 2, 2021 in SQL by dev_sk2311 (45k points)
0 votes
1 answer

Browse Categories

...