Looking for a Tutor Near You?

Post Learning Requirement »
x

Choose Country Code

x

Direction

x

Ask a Question

x

x
x
x
Hire a Tutor

ORACLE SQL

Loading...

Published in: Oracle Training
1,253 Views

ORACLE SQL

Debarun S / Kolkata

10 years of teaching experience

Qualification: B.Tech

Teaches: Computer, Mathematics, Science, Chemistry, Computer Science, Physics, School Level Computer, Defence Exams, IBPS, Insurance Exams, SSC Exams

Contact this Tutor
  1. SQL Wildcards SQL Wildcard Characters A wildcard character is used to substitute any other character(s) in a string. Wildcard characters are used with the SOL LIKE operator. The LIKE operator is used in a WHERE clause to search for a specified pattern in a column. There are two wildcards used in conjunction with the LIKE operator: % - The percent sign represents zero, one, or multiple characters - The underscore represents a single character Note: MS Access uses a question mark (?) instead of the underscore (_). In MS Access and SQL Server you can also use: [charlist] - Defines sets and ranges of characters to match [Acharlist] or [!charlist] - Defines sets and ranges of characters NOT to match The wildcards can also be used in combinations! Here are some examples showing different LIKE operators with '%' and wildcards: LIKE Operator WHERE CustomerName LIKE WHERE CustomerName LIKE WHERE CustomerName LIKE '%or%' WHERE CustomerName LIKE r%' WHERE CustomerName LIKE WHERE ContactName LIKE 'a%o' Demo Database Description Finds any values that starts with "a" Finds any values that ends with "a" Finds any values that have "or" in any position Finds any values that have "r" in the second position Finds any values that starts with "a" and are at least 3 characters in length Finds any values that starts with "a" and ends with "o"
  2. Below is a selection from the "Customers" table in the Northwind sample database: CustomerID CustomerName ContactName Address City PostalCode Country 1 2 3 4 5 Alfreds Futterkiste Maria Anders Ana Trujillo Emparedados y helados Antonio Moreno Taquerfa Around the Horn Berglunds snabbköp Ana Trujillo Antonio Moreno Obere Str. 57 Avda. de la Constituci6n 2222 Berlin 12209 México 05021 D.F. México Mataderos 2312 05023 D.F. 120 Hanover London WAI IDP Thomas Hardy sq. Christina Berguvsvägen 8 Luleå S-958 22 Berglund Germany Mexico Mexico UK Sweden Using the % Wildcard The following SQL statement selects all customers with a City starting with "ber": Example SELECT * FROM Customers WHERE City LIKE 'ber%', The following SQL statement selects all customers with a City containing the pattern "es" Example SELECT * FROM Customers WHERE City LIKE Using the _ Wildcard The following SQL statement selects all customers with a City starting with any character, followed by "erlin": Example SELECT * FROM Customers WHERE City LIKE ' eriin'•,
  3. The following SQL statement selects all customers with a City starting with "L", followed by any character, followed by "n", followed by any character, followed by "on" Example SELECT * FROM Customers WHERE City LIKE Using the [charlist] Wildcard The following SQL statement selects all customers with a City starting with "b" s' , or "p" Example SELECT * FROM Customers WHERE City LIKE '[bsp]%'; The following SQL statement selects all customers with a City starting with "a", "b", or c Example SELECT * FROM Customers WHERE City LIKE Using the [!charlist] Wildcard The two following SQL statements select all customers with a City NOT starting with "b", s or "p" Example SELECT * FROM Customers WHERE City LIKE Or: Example SELECT * FROM Customers WHERE City NOT LIKE