This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- MySQL example of last index of, looking for the / | |
SELECT LENGTH("/HELLO/WORLD/STRINGS") - INSTR(REVERSE("/HELLO/WORLD/STRINGS"), "/") + 1; | |
13 | |
-- T-SQL example of last index of, looking for the / | |
SELECT LEN('/HELLO/WORLD/STRINGS') - CHARINDEX('/', REVERSE('/HELLO/WORLD/STRINGS')) + 1; | |
13 | |
-- MySQL example of cutting off the last segment of a path | |
SELECT SUBSTR("/A/B/C", 1, LENGTH("/A/B/C") - INSTR(REVERSE("/A/B/C"), "/")); | |
/A/B | |
-- T-SQL example of cutting off the last segment of a path | |
SELECT SUBSTRING('/A/B/C', 1, LEN('/A/B/C') - CHARINDEX('/', REVERSE('/A/B/C'))); | |
/A/B |
awesome. btw your gists still don't show up in the feed.
ReplyDeleteI'm loving the gists because 1) it looks good and 2) blogger doesn't foobar my code when saving a post -- but I'm not sure if I can get the gists to render content that will be picked up by feed readers as it is inserted with a script tag. I'm going to look in to this and I have some ideas on how it might be done...
ReplyDeleteOh, and 3) the gist is stored in version control and you can go back and edit it.
ReplyDeleteHi David,
ReplyDeleteThis was really helpful.
Thank you! Just what I was looking for.
ReplyDelete- Juha S
thank you for the solution
ReplyDeleteDevrim K
Perfect !! Exactly what I needed :)
ReplyDeleteNice! Thank you.
ReplyDelete