Jump to content

Post Code search to return B, B18, B34 etc, not BA12 BA1, etc etc


scotchegg78

Recommended Posts

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

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?

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.