IT: Find a specific letter in SQL

 

So what is the benefit of SQL, also known as Oracle? Well you can keep track of your customers records easily for one thing. Second, it is secure, so no one, unless you give them permission, will access this information. Below you will see one of the basics of SQL.

How to find a single letter in a data input in SQL:

Example: Give the names of ice cream flavors that have a ‘t’ and an ‘e’ in their names in that order?

select Ice_cream_flavor from ICECREAM where lower(Ice_cream_flavor)  like ‘%t%e%’;

select Ice_cream_flavor from ICECREAM where upper(Ice_cream_flavor)  like ‘%T%E%’;

Notice that in lower the like letters are lower case, and in upper the like letters are uppercase. This makes a difference.

Output:

SQL> select Ice_cream_flavor from ICECREAM where lower(Ice_cream_flavor)  like ‘%t%e%’;

ICE_CREAM_FLAVOR

—————-

Chocolate

Strawberry

OR

select Ice_cream_flavor from ICECREAM where upper(Ice_cream_flavor)  like ‘%T%E%’;

ICE_CREAM_FLAVOR

—————-

Chocolate

Strawberry

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s