I've got two questions Given a column called URL (in a links table) that contains examples of url's.
Things like http://facebook.com/hello i need to extract everything till the first / so http://facebook.com or https://www.cnn.com/video/data/2.0/video/tech/2014/10/30/pkg-future-of-travel-jet-engine-leap-plane.cnn.html the output would be https://cnn.com
This is what I have but i'm not sure if its accurate logic.
select distinct SUBSTRING (url,0,(CHARINDEX('/'), URL,0)) from links
Also I need a MYSQL version. Which i'm not entirely sure is what I've got. Please advise. Thank you