PHP MYSQL search for postcode using LIKE -
i have query searches postcode using like. postcode fine if puts full postcode e.g. sw14 4np. if put in sw1 return sw1+ results. how can make if put sw1, display sw1 postcode , not sw11, sw14 etc.
my query is:
select postcode data postcode '$search%'
the database postcodes stored sw14 4np etc space.
use regular expression based pattern matching:
where postcode rlike '^$search( ?[0-9][a-z]{2})?'