Hia, I'm struggling a bit while forming some SQL queries. Currently I'm using:

InStrRev(TABLE.[_URL],"/")+1) AS OUTPUT

Given an input of a URL - I want to extract the last part eg:

www.url.com/some/text/here

Should return

here

There are always 3 slashes and while the snippet I posted works perfectly; only within access.

When I try and use this outside of access - I find errors - any advice on alternatives available to me?

有帮助吗?

解决方案

As you have discovered, SQL queries executed from within Access can use many VBA functions (like InStr() and InStrRev()) that are not natively supported by the Jet/ACE dialect of SQL. One of the most powerful aspects of Access' "extensions" to Jet/ACE SQL is that you can even write your own VBA functions and use them in Access queries.

Unfortunately, things can get a bit confusing when it comes to what functions are supported in "plain" Jet/ACE SQL because many of the names are the same. If we can use Left(), Right(), Mid(), etc. in queries against Jet/ACE databases executed outside of Access, then why not InStr() and InstrRev()? The answer is, unfortunately, "Just because.".

In your particular case I agree with Remou's comment that you'll probably just have to retrieve the entire column value in your query and then do the [equivalent of the] InStrRev()-related parsing afterward.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top