All,

    I have a question as how I can return some results that I am looking
for.  Ideally I'd like to run this sql statement but for some reason MySql
won't allow me to run it:


SELECT
  *
FROM
  zip_code
WHERE
  zg_latitude between ((select zg_latitude from zip_code where zg_zipcode =
'78730')- 2) and
  ((select zg_latitude from zip_code where zg_zipcode = '78730') + 2)  and
  zg_longitude between ((select zg_longitude from zip_code where zg_zipcode
= '78730') - 2) and
  ((select zg_longitude from zip_code where zg_zipcode = '78730') + 2)

I get an error to check the mysql manual.  This statement runs in an oracle
environment though.

I guess I am stuck with writing multiple queries and them tying them
together.  In PHP how can I put a variable into the sql statement (if that's
possible).  Let's say I have these queries:
select zg_longitude from zip_code where zg_zipcode = '78730'

This one pulls the zg_longitude from the zip_code table where the zip_code
is 78730 for instance.  I want to take the result (one record) and put it in
this sql statment replacing 'result here':

select * from zip_code
where zg_longitude >= ('result here'-2)
and zg_longitude <= ('result here'+2)
order by zg_city asc

Can anyone help me with this or point me in a better direction?

Thanks

-Rich





Reply via email to