The SQL SUBSTR function is used to extract a sub-string from a string. It takes three arguments: the string, the starting position, and the length of the sub-string.

Here is an example of how to use the SUBSTR function in SQL:

SELECT SUBSTR('Hello, World!', 8, 5) AS sub_string;

This query will return the sub-string 'World' because it starts at position 8 and has a length of 5 characters.

You can also use the SUBSTR function with a column name instead of a string literal. For example:

SELECT SUBSTR(column_name, 3, 4) AS sub_string
FROM table_name;

This query will return the sub-string of the specified column starting at position 3 and having a length of 4 characters for each row in the table.

SQL SUBSTR Function: Extract Substrings from Strings

原文地址: https://www.cveoy.top/t/topic/pTIw 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录