Home > database >  Get path of url in SQL
Get path of url in SQL

Time:09-27

I have a column filled with strings in url format, i.e. starting with https:// and ending with /path1/path2/path3/?v=abc//123.

I would like to select this column in a way so that I only include the path of the url (excluding the last trailing /character), so that the resulting string becomes /path1/path2/path3.

I have been looking for an answer, but have not found anything meaningful for my case so far.

Edit: The data is stored in Google BigQuery

CodePudding user response:

Find the location of /? and grab everything to the left of that

 SELECT LEFT(path_string,STR_POS(path_string,'/?')-1) AS baseURL

Docs are here enter image description here

  • Related