Allow2010 Posted January 21, 2018 Share Posted January 21, 2018 (edited) Hi, I want to query a firebird database. Everything works fine, but i need to optimize my query so the results will be ok. Each row of my table holds a customer with collumns like lastname, firstname, phone1, phone2, fax and mobile My script has a phonenumber and i want to find alle customers with that phonenumber (yes, the number can be used by more than one customer). Right now i use something like: $sQUERY = 'Select * from ' & $sTableName & " WHERE PHONE1 LIKE '%" & $number & "%'" As long as the number is stored correctly it works fine, but sometimes there are spaces or comments in the stored number or a number is written in different ways like 089-123456 or like 089/123456 or like 089123456. How can i construct a query to only compare the numeric part (that means strip letters and whitespaces) of the phone1 column (and also the other phone columns)? Only using wildcards like % and _ (that is waht i do now) is probably not enough. I need something a bit more complicated :-) On the web i found examples using substring with something like %[0-9]% but i am not sure if this syntax is supported by the firebird db and even if it is, i did not manage to get it working. Can anyone help me here? Thanks! Edited January 21, 2018 by Allow2010 Link to comment Share on other sites More sharing options...
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!Register a new account
Already have an account? Sign in here.Sign In Now