On 24/04/2012 17:11, Tompkins Neil wrote:
Hi
I've a number of different postal codes in a system for example
WC1B 5JA
WC1H 8EJ
W1J 7BX
W1H 7DL
NW1 1NY
I can use like statements for example
SELECT * FROM postal_codes WHERE zip LIKE 'W1%' giving me
W1J 7BX
W1H 7DL
In addition I have a number of abbreviated postal codes like
W1
WC1
WC2
NW1
Now, if I know the postal code W1J 7BX what is the best way using a MySQL
query to get the abbreviated postal codes W1. Same if I have the postal
code WC1H 8EJ, how do I get the abbreviated postal codes WC1
Can I use any matching patterns ?
http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html
Specifically, replace % with _ as this means "match one character" not
"match any number of characters". So, you can do:
like "W1 %"
like "W1_ %"
etc.
Does that help?
Gary
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql