Reputation: 1053
I have an Image path Field in the table and I want to get path without filename and it's an extension.
I tried using the POSITION of the charecture way but didn't get the accurate output.
LEFT("My_Path", POSITION('\' IN REVERSE("My_Path")) - 1)
The file path is something like
\Nikunj\Images\1.png
My expected result is
Nikunj\Images\
Upvotes: 0
Views: 1639
Reputation: 31676
Simply use SUBSTRING
select substring (mypath from '(^.*\\)' ) ;
Upvotes: 2
Reputation: 1053
Thank you, friends, I got a solution for that and this is my solution.
concat(RTRIM(REPLACE(My_Path, reverse(substring(reverse(My_Path) from 1 for strpos(reverse(My_Path),'\')-1)),''),'\'),'\') AS VolumePath
This solution may help you in the feature.
Thanks for your answers friends.
Upvotes: 0
Reputation: 144
Try following example it is working correctly.
SELECT concat(SPLIT_PART('\Nikunj\Images\1.png', '\', 2),'\',SPLIT_PART('\Nikunj\Images\1.png', '\', 3),'\') as c2;
Upvotes: 0