Need help about SQL LIKE statement

Asked By 0 points N/A Posted on -
qa-featured

I need to know how the LIKE statement is working in a query.

Please give me some examples. 

SHARE
Best Answer by Norwood-Koonce
Best Answer
Best Answer
Answered By 0 points N/A #157416

Need help about SQL LIKE statement

qa-featured

Well,

“LIKE” is clause that use in any SQL query to retrieve data which have particular part or phase of a particular column we specified with that.

When we need to write a query that need to retrieve names from a column that store set of names which starts with certain characters or which having certain characters in the middle of  the name.

See below example.

Assume we need to retrieve all data which the user name starts with ‘sa’ (assume the column’s name is username)

SELECT * FROM <table name>

WHERE username LIKE ‘sa%’

*The “%” marks meaning is any amount of characters after ‘sa’

If you need to retrieve user names which having ‘sa’ in the middle of the usernames,

SELECT * FROM <table name>

WHERE username LIKE ‘%sa%’

Answered By 590495 points N/A #157417

Need help about SQL LIKE statement

qa-featured

The SQL LIKE operator is applied when using a WHERE clause. Its function is to look for a particular pattern in a column. Below is the proper syntax for the SQL LIKE operator:

Here is an example of how the LIKE operator is used. In the table below you will see names of persons living in the city. Now, what we want to do is to select the persons that end with an “s”.

To do this, we apply the following statement:

The “%” symbol beside the letter “s” is used to indicate or define wildcards. It can be placed either before or after the specified pattern or more precisely before or after the letter “s”. The result would be:

Answered By 0 points N/A #157418

Need help about SQL LIKE statement

qa-featured

Hello adviser, take my compliments for your precious comments. Although, the SQL LIKE operator is difficult for me with a limited knowledge but I am interested to write better filter expressions with the SQL LIKE operator, so I need your help. Everyone comments were comprehensible but Norwood-Koonce your comments made me puzzled to realize my task for your complex description. Sharath your explanation with example was very reliable and easy-to-use to me, for that your comments touched my mind. For your example, now I am able to configure my task and I can easily manage the SQL LIKE operator that base on your example in the comment. Thanks Sharath, I will get into a scrap if you will not help me.

Related Questions