Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql查询获取子字符串_Sql - Fatal编程技术网

Sql查询获取子字符串

Sql查询获取子字符串,sql,Sql,嗯,总是需要标记DBMS(MySQL,SQL Server,Oracle,等等)您在使用什么 在SQL Server中,charindex()函数可用于获取指定字符的索引() 以类似的方式,您可以使用substring()函数指定具有所需字符串长度的字符串的起始位置 Row values: Automation > Consumables > Ladle Cup 2 Kg > i need Output:Automation I Need First > inside

嗯,总是需要标记DBMS(
MySQL
SQL Server
Oracle
,等等)您在使用什么

在SQL Server中,
charindex()
函数可用于获取指定字符的索引(

以类似的方式,您可以使用
substring()
函数指定具有所需字符串长度的字符串的起始位置

Row values:
Automation > Consumables > Ladle Cup 2 Kg >
i need Output:Automation 
I Need First > inside values

Row values:
Consumables > Automation > Ladle Cup 2 Kg >
i need Output:`enter code here`Consumables 
I Need First > inside values

您正在使用哪些数据库管理系统,如SQL server、MySQL?为该问题添加标记…问题不清楚请以表格格式提供表格架构和数据,以便进一步理解
SELECT 
        Row_Value,
        substring(<Row_Value>, 1, charindex('>', <Row_Value>)-1) New_Row_Value
FROM table
Row_Value                                     New_Row_Value           
Automation > Consumables > Ladle Cup 2 Kg >    Automation
Consumables > Automation > Ladle Cup 2 Kg >    Consumables