I have a Store
table containing a deliveryPostcodes
field, which is a comma-separated list of postcode areas:
id deliveryPostcodes
1 EC1,EC2,N1
2 EC1,WC1,WC2
3 N1,N2
I'd like to query this table for stores matching a postcode, for example if the user enters EC2A 9XY
, it should return the first row, as this one has an entry in the list that is a prefix of the full postcode.
Is there a solution to do that without a custom function?
Note: I know I could do this by joining a separate table with one postcode area per line, but I'm exploring the different options for now.