Axeia Posted May 15, 2009 Share Posted May 15, 2009 Okay, I got a string like the one below. [Ayako]_Tayutama_-_03_[XVID+MP3_704x400][DAC23715].mkv And I got this in my database elsewhere: [Ayako]_Tayutama_-_ Now I need the second string when used in a query to bring up the first one as a result, so I got my script to write the following string: SELECT * FROM Unchecked WHERE Filename REGEXP( "\[Ayako\]_Tayutama_-_") This does however not work, from some manual editting it seems it stops working as soon as the underscore is used. SELECT * FROM Unchecked WHERE Filename REGEXP( "\[Ayako\]") works fine. SELECT * FROM Unchecked WHERE Filename REGEXP( "\[Ayako\]_") does not I thought it was a sqlite bug, but my Eclipse regex plugin runs into trouble with the underscore as well, what's so special about that underscore? Even this wont work: SELECT * FROM Unchecked WHERE Filename REGEXP( "\[Ayako\].Tayu") This however does: SELECT * FROM Unchecked WHERE Filename REGEXP( "\[Ayako\].+Tayu") What's going on here? Quote Link to comment Share on other sites More sharing options...
AmandaF Posted May 15, 2009 Share Posted May 15, 2009 http://dev.mysql.com/doc/refman/6.0/en/pattern-matching.html Apparently _ is the equivalent of . in SQL regex. ??? I guess you could try escaping it. Quote Link to comment Share on other sites More sharing options...
Axeia Posted May 15, 2009 Author Share Posted May 15, 2009 Did try that already , no luck. Might also be worth noting that I'm working with sqlite(3) (via the PDO class) instead of mysql. Quote Link to comment Share on other sites More sharing options...
.josh Posted May 15, 2009 Share Posted May 15, 2009 SELECT * FROM Unchecked WHERE Filename LIKE "[Ayako]_Tayutama_-_%" Quote Link to comment Share on other sites More sharing options...
Axeia Posted May 16, 2009 Author Share Posted May 16, 2009 That was my first approach, but ran into some problems as the second part would be some number matching where the number is greather than n. Guess I'll just let PHP do some of the work and indeed let a LIKE handle the first part. Was hoping to do as much as possible in sql for ease of porting to other programming languages. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.