If you're trying to do this from within the table, I am not sure it will work. However, if you're doing this using a query, then I think it could work. Otherwise, I can think of two other options.
- Do it using code, or
- Do it using SharePoint (in other words, create a landing page in SharePoint, so the link are all the same; but also, passes the ID to the link and then have SharePoint redirect to the actual link)