How do I retrieve this: 123
from this: 123?arg=value#ancor
, in MYSQL; in other words, removing queries and removing anchors from the 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 * FROM 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 will always be numeric, but can be any length.
UPDATE 2: revised_path() is a temporary replacement for the solution I'm looking for.