Jump to content

Anyone help with this simple query


DanielStead

Recommended Posts

This query works fine

 

SELECT ParcelID, x, y FROM Polygons WHERE Parish = 'Stadhampton' AND ParcelID = 91 AND x BETWEEN 460500 AND 461000

 

but this query selects multipule ParcelID's when i only want the ones for 91. It seems to be the OR that causes the query not to function as how i thought it would.

 

SELECT ParcelID, x, y FROM Polygons WHERE Parish = 'Stadhampton' AND ParcelID = 91 AND x BETWEEN 460500 AND 461000 OR y BETWEEN 199000 AND 199500

 

In english i want the query to select PareclID, x and y if parish = stadhampton and ParcelId = 91 and (if (x is between 460500 and 461000) OR (y is between 199000 AND 199500)

 

Can anyone help me with this?

 

Link to comment
https://forums.phpfreaks.com/topic/3046-anyone-help-with-this-simple-query/
Share on other sites

[!--quoteo(post=327336:date=Dec 14 2005, 04:49 PM:name=DanielStead)--][div class=\'quotetop\']QUOTE(DanielStead @ Dec 14 2005, 04:49 PM) 327336[/snapback][/div][div class=\'quotemain\'][!--quotec--]

This query works fine

 

SELECT ParcelID, x, y FROM Polygons WHERE Parish = 'Stadhampton' AND ParcelID = 91 AND x BETWEEN 460500 AND 461000

 

but this query selects multipule ParcelID's when i only want the ones for 91. It seems to be the OR that causes the query not to function as how i thought it would.

 

SELECT ParcelID, x, y FROM Polygons WHERE Parish = 'Stadhampton' AND ParcelID = 91 AND x BETWEEN 460500 AND 461000 OR y BETWEEN 199000 AND 199500

 

In english i want the query to select PareclID, x and y if parish = stadhampton and ParcelId = 91 and (if (x is between 460500 and 461000) OR (y is between 199000 AND 199500)

 

Can anyone help me with this?

 

Try this daniel:

 

select PareclID, x and y FROM Polygons WHERE ((Parish = 'Stadhampton' AND ParcelID = 91) || ((x BETWEEN 460500 AND 461000)|| (y BETWEEN 199000 AND 199500)))

 

 

I'm really horrible at this stuff (and new) and have no clue really but is there a possibilty that grouping [x BETWEEN 460500 AND 461000 OR y BETWEEN 199000 AND 199500] together might help...I think im trying to say so that it looks for 3 sections of infomation (the Parish, ParcelID, and then that group)..?...or maybe put x and its numbers and y and its number to variables..?...maybe using the group by clause..?...

 

Sorry, I duno..just thought I would say a couple ideas that come to mind...

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.