![]() ![]() You can mix the wildcard characters in a pattern. The pattern 'Je_i' matches any string that starts with 'Je', followed by one character, and then followed by 'i' e.g., Jeri or Jeni, but not Jenni. The following example finds the phone numbers and emails of contacts whose first names have the following pattern 'Je_i': SELECTĬode language: SQL (Structured Query Language) ( sql ) The result is: B) _ wildcard character examples The following example uses the NOT LIKE operator to find contacts whose phone numbers do not start with '+1': SELECTįirst_name Code language: JavaScript ( javascript ) LOWER(last_name LIKE 'st%' Code language: JavaScript ( javascript )įor example, the following statement finds emails of contacts whose first names start with CH: SELECTįirst_name Code language: SQL (Structured Query Language) ( sql ) To perform a case-insensitive match, you use either LOWER() or UPPER() function as follows: UPPER( last_name ) LIKE 'ST%' Matches any string that ends with the 'er' string. To find the phone numbers of contacts whose last names end with the string 'er', you use the following statement: SELECT The LIKE operator matched any string that starts with 'St' and is followed by any number of characters e.g., Stokes, Stein, or Steele, etc. In this example, we used the pattern: 'St%' Code language: JavaScript ( javascript ) The following picture illustrates the result: Last_name Code language: JavaScript ( javascript ) The following example uses the % wildcard to find the phones of contacts whose last names start with 'St': SELECT We will use the contacts table in the sample database for the demonstration: A) % wildcard character examples Let’s take some examples of using the Oracle LIKE operator to see how it works. The NOT operator, if specified, negates the result of the LIKE operator. The LIKE operator returns true if the expression matches the pattern. The escape_character, if specified, must be one character and it has no default value. The escape_character is a character that appears in front of a wildcard character to specify that the wildcard should not be interpreted as a wildcard but a regular character. ![]() _ (underscore) matches any single character.% (percent) matches any string of zero or more character.The pattern includes the following wildcard characters: The pattern is a string to search for in the expression. The expression is a column name or an expression that you want to test against the pattern. The syntax of the Oracle LIKE operator is as follows: expresion LIKE pattern Code language: CSS ( css ) In this case, you use the Oracle LIKE operator. For example, you may want to find contacts whose last names start with 'St' or first names end with 'er'. Sometimes, you want to query data based on a specified pattern. Summary: in this tutorial, you will learn how to use the Oracle LIKE operator to test whether values in a column match a specified pattern. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |