hope this helps...
On Thu, 2005-04-07 at 08:50 +0200, Juffermans, Jos wrote:
Hi, I'm afraid I can't help you with the query - I'm used to Oracle which as a bigger set of SQL commands. I can help you with your PHP question. If you want to put a variable in a query, you can add the variable directly into the string: $sql_query = "select zg_longitude from zip_code where zg_zipcode = '$zipcode'"; Or (my favorite choice) you can break the string and add the variable with .'s: $sql_query = "select zg_longitude from zip_code where zg_zipcode = '" . $zipcode . "'"; With the first option, it is not always clear what is the variable and what not. Jos -----Original Message----- From: ReClMaples [mailto:[EMAIL PROTECTED]] Sent: 07 April 2005 06:04 To: PHP Subject: [PHP-DB] MySql and PHP question 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
-- Jeffrey D. Means [EMAIL PROTECTED] Owner / CIO for MeansPC http://www.meanspc.com/ Custom Web Development For Your Needs. (970)308-1298 My Public PGP Key ID is: 0x81F00126 and available via: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x81F00126
Description: This is a digitally signed message part