• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1735
  • Last Modified:

InStrRev

Im trying to get a result to return only the paths out of my hard drive, through a database, I have imported all files on my hard drive into the database.

When I query through Access I use:-
     SELECT Left([path],InStrRev([path],"\")) AS Expr1
     FROM scanned
     GROUP BY Left([path],InStrRev([path],"\"));
and get 40 rows back, whatever I try in MySql I only get half the rows back. I know my probelm is cause MySql doesnt support 'InStrRev', but cant see any similar functions.

I have tried to make my own instrrev like this "length(`path`) - INSTR(reverse(`path`),"\\"))) "

InstrRev is the same as instr, but returns the last value in the string, instead of where it found it first.
0
tonelm54
Asked:
tonelm54
  • 2
1 Solution
 
mssturgeonCommented:
Try this:
     SELECT REVERSE( SUBSTRING( REVERSE([path]), LOCATE("\\")+1) AS Expr1
     FROM scanned
     GROUP BY Expr1;
0
 
mssturgeonCommented:
oops, slight revision:

     SELECT REVERSE( SUBSTRING( REVERSE([path]), INSTR(REVERSE([path]), "\\")+1) AS Expr1
     FROM scanned
     GROUP BY Expr1;
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now