sql - How to get certain word from a column value -
column /site/test1/mysite/do?id=90 /site/test2/mysite/done?id=10 /newsite/site/test3/mysite/do?id=90 /site/test3/mysite/done?id=1901 what trying test# each row # after =.
i tried following:
select substring(column a, charindex('/', column a, 1) + 7, len(column a)), substring(column a, charindex('=', column a, 1) + 1, len(column a)), column table1 i able # after = how can test# each row.
update: test# example, can in there. site , newsite.
update #2:
updated table:
column /site/my%20web%20site/mysite/do?id=90 /site/test%20it%20out/mysite/do?id=101 /site/test1/dummy/done?id=1000 /newsite/site/no%20way/thesite/do?id=909 result:
col1 col2 my%20web%20site 90 test%20it%20out 101 test1 1000 no%20way 909
select col1 = substring(a , charindex('/site/', a)+6 , charindex('/', a,(charindex('/site/', a)+6))-(charindex('/site/', a)+6) ) , col2 = substring(a , charindex('=', a, 1) + 1 , len(a)) t rextester demo: http://rextester.com/debb37305
returns:
+-----------------+------+ | col1 | col2 | +-----------------+------+ | my%20web%20site | 90 | | test%20it%20out | 101 | | test1 | 1000 | | no%20way | 909 | +-----------------+------+
Comments
Post a Comment