SUBSTRING method is used to extract particular characters of specified length from the given expression.
For e.g:- from the string "Blogger", If we want to extract the word "Blog" then we will use the
SUBSTRING method as :-
SUBSTRING("Blogger",1,4)
Syntax of SUBSTRING is :-
SUBSTRING(expression,starting_position int,Length int)
e.g:- We have a Products table as:-
We use a query as:-
SELECT SUBSTRING(pname,1,3)
FROM Product
WHERE pname = 'clogate';
Then the result of the above query will be "clo".
stating position is 1 and it will take 3 characters from 1st index.
For e.g:- from the string "Blogger", If we want to extract the word "Blog" then we will use the
SUBSTRING method as :-
SUBSTRING("Blogger",1,4)
Syntax of SUBSTRING is :-
SUBSTRING(expression,starting_position int,Length int)
e.g:- We have a Products table as:-
We use a query as:-
SELECT SUBSTRING(pname,1,3)
FROM Product
WHERE pname = 'clogate';
Then the result of the above query will be "clo".
stating position is 1 and it will take 3 characters from 1st index.
No comments:
Post a Comment