Hello Folks,
I have a field ' postalcity ' where postal code and city is stored and separted by a space
exemple
1000 Berlin
2000 Munich
1000 Berlin
2500 Frankfurt
Now I need a query , for exemple to get me all the records with postal c greater than 2000
something like
SELECT * from table WHERE first4charsof (postalcity)>='1000';
Can anybody help me with this query?
Thanks in Advance
WHERE $postal = first 4 chars of Postalcity
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
SELECT * FROM table WHERE `postalcity` LIKE '1000%'Code: Select all
SELECT * FROM table WHERE `postalcity` REGEXP '^1000'-
magicrobotmonkey
- Forum Regular
- Posts: 888
- Joined: Sun Mar 21, 2004 1:09 pm
- Location: Cambridge, MA
i believe that, due to the nature of strings and comparisons, you dont need to worry about getting the first four chars. Just make sure that whatever you are comparing against is a string as well i.e. see how the 1000 is in quotes?
Code: Select all
SELECT * FROM Table WHERE Postal Code > '1000'