DATABASE & SQL/PLSQL

Displaying Rows Using String Operator
Previous Home Next

Using String Operator

String operator provide a LIKE keyword to search for a string with wild card mechanism.

DtatypeRange
%Represents any string of Zero or more character
_Represent the single character
[]Represent any single character within the specified range
[^]Represent any single character not within the specified range

 

Example:

SELECT *
FROM titles
WHERE type LIKE 'bus%'

Return all attribute from the titles table in which the type starts with 'bus'

SELECT *
FROM titles
WHERE type LIKE 'bu_'

Return all attribute from the titles table in which the type of book is the three character long and  starts with 'bu'. Increase the '_' keyword increase the number of characters.

SELECT *
FROM titles
WHERE type LIKE 'b[us]%'

Return all attribute from the titles table in which the type of book is starts with 'b' and contain u and s on the second position followed by any number of character.

SELECT *
FROM titles
WHERE type LIKE 'b[^s]%'

Return all attribute from the titles table in which the type of book is starts with 'b' and does not contain s on the second position followed by any number of character.

Some Example

ExpressionReturns
LIKE '%ty%' All names that have the letters 'ty' in them
LIKE '_ty'All three letter names ending with 'ty'
LIKE '[AD]%'All name that begin with "A" or "K"
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: