例如
Heiniger, Hans Hans
Müller, Nehla Nehla
我试过这个:
SELECT SUBSTRING(NAME FROM 1 FOR POSITION(',' IN NAME)) FROM OBJ_R
答案 0 :(得分:1)
select substring_index(name, ',', -1) as first_name
答案 1 :(得分:0)
在MS SQL Server中,查找字符串中字符的第一个位置?
可以使用CHARINDEX或PATINDEX。
select ltrim(substring(NAME, charindex(',', NAME)+1, len(NAME))) as FirstName
from OBJ_R
获得第一部分:
select case when charindex(',',NAME) > 0 then substring(NAME,0,charindex(',',NAME)-1) else NAME end as LastName
from OBJ_R