On Tue, Apr 24, 2012 at 12:24 PM, Tompkins Neil <neil.tompk...@googlemail.com> wrote: > How about if I want to only return postal codes that are like W1U 8JE > not W13 0SU. > > Because in this example I have W1 as the postal code and W13 is the other > postal code
Perhaps something like following? Though, to be honest, I'm not sure what rules you need to follow, and how to best resolve ambiguities, if any should arise. Both long_postal and short_postal tables contain a single varchar column holding their respective codes. select lp.code long_code, sp.code short_code from long_postal lp, short_postal sp where sp.code = substring(lp.code, 1, length(sp.code)); or, given a particular long postal code select sp.code from short_postal sp where sp.code = substring('W1U 8JE', 1, length(sp.code)) Indices won't be of too much help for the short_postal table, I imagine, for this kind of query.. Lars Nilsson -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql