Introduction:
Here I will explain how to get data between two characters range in SQL server or get user details start with A-C range in SQL server.
Here I will explain how to get data between two characters range in SQL server or get user details start with A-C range in SQL server.
Description:
In previous articles
I explained Acid Properties in SQL Server, Query to get database size in SQL
Server,
show time difference in minute ago hour
ago etc in SQL Server, can function return multiple values in SQL Server and many
articles relating to SQL
server. Now I will explain how to get data between two characters
range in SQL
server.
I have a requirement like need to get user details whose names between A – C range in SQL server for that I written query like as shown below
SELECT * FROM UserDetails WHERE
Name LIKE '[A-C]%'
|
Whenever we run above query it will return all user
details which are in between [A-C] range
Example
Initially my user details table is like this
Now from table I need to get user details who belongs
in between [A-C] range for that we need to write the code like as shown
below
SELECT * FROM UserDetails WHERE
UserName LIKE '[A-C]%'
Order BY
UserName
|
Once we run above query we will get output like as
shown below
Output
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
3 comments :
Nice blog....
Valuable Code...Thanks
Ni article.
Did some more combinations and found that the where clause LIKE '[A%M]%' will return the searched column ONLY if it has values starting with "A" or "M"
Note: Only a member of this blog may post a comment.