This statement works fine from the mysql prompt:
SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(path, "\\", -2), "\\", 1) AS dir FROM files
But I get a "DBD::mysql::st execute failed" error when I run this:
my $query = qq~
SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(path, "\\", -2), "\\
+", 1) AS dir FROM files
~;
my $sth = $dbh->prepare($query);
my $rv = $sth->execute;
DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '\", 1) AS dir
So, I believe that something is not escaped properly in my statement and I have tried several different ways but no luck.
Any ideas?