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
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)))

 

 

Link to comment
Share on other sites

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...

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.