scotchegg78 Posted October 29, 2007 Share Posted October 29, 2007 Hi guys, Is there way i can make mysql only return my postcode search for one char and 2 numbers/ints? $query_qryData .= " CompanyPostCode LIKE '" . $colname_qryData . "%' AND"; returns all the postcodes starting with the letter B, inclucing invalide B and another letter postcodes like BA etc. of course $query_qryData .= " CompanyPostCode LIKE '" . $colname_qryData . " ' AND"; will just return post codes with the letter B, but postcode in the uk all haev the format of 1 or 2 letters, followed by 1 or 2 numbers. thanks Quote Link to comment Share on other sites More sharing options...
scotchegg78 Posted October 29, 2007 Author Share Posted October 29, 2007 I have used this, is this correct? is there a better way? Query = " CompanyPostCode LIKE '" . $colname_qryData . "%' AND SUBSTRING(CompanyPostCode,2,1) BETWEEN '0' AND '9' AND"; I suspect this leaves out any postcodes with just B though? is there a way to test if its NOT a char in the substring and not if its a number? Quote Link to comment Share on other sites More sharing options...
fenway Posted October 29, 2007 Share Posted October 29, 2007 Yes... with REGEXP. 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.