Extract path in MYSQL -


how retrieve this: 123 this: 123?arg=value#ancor, in mysql; in other words, removing queries , removing anchors url path.

example scenario:

table1: +----+------+ | id | path | +----+------+ |  1 |  100 | |  2 |  200 | |  3 |  300 | +----+------+  table2: +----+----------------+ | id |           path | +----+----------------+ |  1 |     100#anchor | |  2 |  200?arg=value | |  3 |      other/300 | +----+----------------+  select * table1 inner join table2 on table1.path = revised_path(table2.path)  result: +----+------+----+---------------+ | id | path | id |          path | +----+------+----+---------------+ |  1 |  100 |  1 |    100#anchor | |  2 |  200 |  2 | 200?arg=value | +----+------+----+---------------+ 

update: path numeric, can length.

update 2: revised_path() temporary replacement solution i'm looking for.

so looks path part of url. php function parse_url trick.

$sql = "select * table1 inner join table2 on table1.path = revised_path(table2.path)"; $result = mysql_query($sql); while ($data = mysql_fetch_object)) {     $path = parse_url($data->path); }  // more code diplay $path etc... 

php documentation on parse_url


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -