Jump to content


Photo

Anyone help with this simple query


  • Please log in to reply
2 replies to this topic

#1 DanielStead

DanielStead
  • Members
  • Pip
  • Newbie
  • 6 posts

Posted 14 December 2005 - 08:49 AM

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?


#2 diskhub

diskhub
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 14 December 2005 - 09:12 AM

[!--quoteo(post=327336:date=Dec 14 2005, 04:49 PM:name=DanielStead)--][div class=\'quotetop\']QUOTE(DanielStead @ Dec 14 2005, 04:49 PM) View Post[/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?
[/quote]

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



#3 angel_cowgirl

angel_cowgirl
  • Members
  • PipPip
  • Member
  • 17 posts
  • LocationPoedunk America

Posted 14 December 2005 - 09:13 AM

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





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users