Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Enterprise
Expertise: Beginner
Apr 10, 2000

Use of LIKE in SQL

The LIKE statement is often used in SQL queries with wildcards to find data that is similar to a matching pattern. PL/SQL has two forms of wildcard: _ and %.

The "_" matches a single character, while "%" matches n number of characters. The _ is faster than % because only one character needs to be evaluated; "%" must perform look-ahead parsing. "_" also works a little differently than "%" because it requires that a match exist, whereas "%" does not have this requirement.

Consider the following statement:

 select * from table_name where 'JAMES' like 'Jame_';
This will match; but you won't get a match with the following:
 select * from table_name where 'Jane' like 'Jane_';
You would, however, get a match if the previous statement was written as follows:
 select * from table_name where 'Jane' like 'Jane%';
There is a tendency to use "%" with all LIKE statements. When the exact number of characters to be matched is known, it is more efficient to use "_".
Jayanta Sengupta
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date