Help with a SQL query.. |
[eluser]slowgary[/eluser]
If you already know the full zip codes that you want to search, you should use a WHERE IN() query, like so: Code: SELECT * FROM `stores` WHERE `store_zip` IN ('12345', '12346', '90266') AND `UPS` = 1; CodeIgniter has a where_in() method that will create this query if you pass it an array. Sounds more like what you need. Something that may also be helpful is a zip code library by Iverson packaged with GandyXT. You can find it here: http://www.gandylabs.com/ci/gandyext
[eluser]Zack Kitzmiller[/eluser]
Right, I already have a list of Zips (can't do it the first want, because the iPhone add returns lat and lon from the GPS, and provides with a user determined range.).. E.G. Show me all locations within 3 miles of my current location. Maybe I need to rephrase. The query works, but won't I don't get back is proper results. I get back ALL stores with the selected option, and all the stores with each zip code. Maybe using where_in will solve it.
[eluser]slowgary[/eluser]
I see. I think the where_in may solve it, as well as be a faster query. Good luck.
[eluser]Zack Kitzmiller[/eluser]
where_in fixed it. Thank you so much! I wish there was a "rep" or "thanks" feature in this system. |
Welcome Guest, Not a member yet? Register Sign In |