If you have a word and you want the ending alphabets(right) or the beginning alphabets(left) to be selected,
you easily use the left and right function as discussed below.
select LEFT('WELCOME',2)
This will return 'WE'
select RIGHT('WELCOME',2)
This will return 'ME'
If you are creative enough you can use the above two functions to select any type of combination from a string.
Example:
select RIGHT(LEFT('WELCOME',5),2)
This will give 'CO' and so on......
You can also avoid the complexity of the above by using the function SUBSTRING as
SELECT SUBSTRING('WELCOME',1,3)
This will give 'WEL'
SELECT SUBSTRING('WELCOME',1,2)
This will give 'WE' and so on.....
Now you can use your creativity to select any parts of the string according to your requirement.
you easily use the left and right function as discussed below.
select LEFT('WELCOME',2)
This will return 'WE'
select RIGHT('WELCOME',2)
This will return 'ME'
If you are creative enough you can use the above two functions to select any type of combination from a string.
Example:
select RIGHT(LEFT('WELCOME',5),2)
This will give 'CO' and so on......
You can also avoid the complexity of the above by using the function SUBSTRING as
SELECT SUBSTRING('WELCOME',1,3)
This will give 'WEL'
SELECT SUBSTRING('WELCOME',1,2)
This will give 'WE' and so on.....
Now you can use your creativity to select any parts of the string according to your requirement.
No comments:
Post a Comment