The SUBSTRING() function in SQL is used to extracts characters from a string.
Syntax : SUBSTRING(string, start_index, length_of_character)
Above Syntax string parameter is the string passed for extraction, start_index is the index where the extraction starts length_of_character is the length of characters to extract from string.
start index of extraction for all string in SQL starting index is always 1.
If you pass negative number in length parameter it will throw and error.
SQL Code 1: SQL get last three chars.
1 2 3 |
select substring(name,length(name)-3) from student |
SQL COde 2: SQL remove last three chars.
1 2 3 |
select name, substring(name,1,length(name)-3) from student |
You may also like: SQL Query Examples(40+)
MySQL substring last 3 characters,
SQL substring last 3 characters,
SQL substring last 3 characters Oracle,